diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2007-10-22 11:42:35 -0400 |
---|---|---|
committer | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2007-10-23 05:19:32 -0400 |
commit | 2042c1c4e7a5e3b69ff3c3c5db6bf6416abd8b24 (patch) | |
tree | 8416e078bfcd15981124694b2526a5a582ebaa5a /arch/avr32/mach-at32ap | |
parent | 86298962c06c2584a8c4df5fb92a70179ca7e4f5 (diff) |
[AVR32] Implement more at32_add_device_foo() functions
Implement functions for adding platform devices for TWI, MCI, AC97C
and ABDAC. They may need to be modified to cope with platform data,
etc. when the corresponding drivers are ready to be merged, but such
changes are much less likely to conflict than adding support for a
whole new type of device.
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Diffstat (limited to 'arch/avr32/mach-at32ap')
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap7000.c | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c index 30aedc9473f..d152504f12b 100644 --- a/arch/avr32/mach-at32ap/at32ap7000.c +++ b/arch/avr32/mach-at32ap/at32ap7000.c | |||
@@ -556,6 +556,17 @@ static struct clk pico_clk = { | |||
556 | .users = 1, | 556 | .users = 1, |
557 | }; | 557 | }; |
558 | 558 | ||
559 | static struct resource dmaca0_resource[] = { | ||
560 | { | ||
561 | .start = 0xff200000, | ||
562 | .end = 0xff20ffff, | ||
563 | .flags = IORESOURCE_MEM, | ||
564 | }, | ||
565 | IRQ(2), | ||
566 | }; | ||
567 | DEFINE_DEV(dmaca, 0); | ||
568 | DEV_CLK(hclk, dmaca0, hsb, 10); | ||
569 | |||
559 | /* -------------------------------------------------------------------- | 570 | /* -------------------------------------------------------------------- |
560 | * HMATRIX | 571 | * HMATRIX |
561 | * -------------------------------------------------------------------- */ | 572 | * -------------------------------------------------------------------- */ |
@@ -655,6 +666,7 @@ void __init at32_add_system_devices(void) | |||
655 | platform_device_register(&at32_eic0_device); | 666 | platform_device_register(&at32_eic0_device); |
656 | platform_device_register(&smc0_device); | 667 | platform_device_register(&smc0_device); |
657 | platform_device_register(&pdc_device); | 668 | platform_device_register(&pdc_device); |
669 | platform_device_register(&dmaca0_device); | ||
658 | 670 | ||
659 | platform_device_register(&at32_systc0_device); | 671 | platform_device_register(&at32_systc0_device); |
660 | 672 | ||
@@ -960,6 +972,96 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) | |||
960 | } | 972 | } |
961 | 973 | ||
962 | /* -------------------------------------------------------------------- | 974 | /* -------------------------------------------------------------------- |
975 | * TWI | ||
976 | * -------------------------------------------------------------------- */ | ||
977 | static struct resource atmel_twi0_resource[] __initdata = { | ||
978 | PBMEM(0xffe00800), | ||
979 | IRQ(5), | ||
980 | }; | ||
981 | static struct clk atmel_twi0_pclk = { | ||
982 | .name = "twi_pclk", | ||
983 | .parent = &pba_clk, | ||
984 | .mode = pba_clk_mode, | ||
985 | .get_rate = pba_clk_get_rate, | ||
986 | .index = 2, | ||
987 | }; | ||
988 | |||
989 | struct platform_device *__init at32_add_device_twi(unsigned int id) | ||
990 | { | ||
991 | struct platform_device *pdev; | ||
992 | |||
993 | if (id != 0) | ||
994 | return NULL; | ||
995 | |||
996 | pdev = platform_device_alloc("atmel_twi", id); | ||
997 | if (!pdev) | ||
998 | return NULL; | ||
999 | |||
1000 | if (platform_device_add_resources(pdev, atmel_twi0_resource, | ||
1001 | ARRAY_SIZE(atmel_twi0_resource))) | ||
1002 | goto err_add_resources; | ||
1003 | |||
1004 | select_peripheral(PA(6), PERIPH_A, 0); /* SDA */ | ||
1005 | select_peripheral(PA(7), PERIPH_A, 0); /* SDL */ | ||
1006 | |||
1007 | atmel_twi0_pclk.dev = &pdev->dev; | ||
1008 | |||
1009 | platform_device_add(pdev); | ||
1010 | return pdev; | ||
1011 | |||
1012 | err_add_resources: | ||
1013 | platform_device_put(pdev); | ||
1014 | return NULL; | ||
1015 | } | ||
1016 | |||
1017 | /* -------------------------------------------------------------------- | ||
1018 | * MMC | ||
1019 | * -------------------------------------------------------------------- */ | ||
1020 | static struct resource atmel_mci0_resource[] __initdata = { | ||
1021 | PBMEM(0xfff02400), | ||
1022 | IRQ(28), | ||
1023 | }; | ||
1024 | static struct clk atmel_mci0_pclk = { | ||
1025 | .name = "mci_clk", | ||
1026 | .parent = &pbb_clk, | ||
1027 | .mode = pbb_clk_mode, | ||
1028 | .get_rate = pbb_clk_get_rate, | ||
1029 | .index = 9, | ||
1030 | }; | ||
1031 | |||
1032 | struct platform_device *__init at32_add_device_mci(unsigned int id) | ||
1033 | { | ||
1034 | struct platform_device *pdev; | ||
1035 | |||
1036 | if (id != 0) | ||
1037 | return NULL; | ||
1038 | |||
1039 | pdev = platform_device_alloc("atmel_mci", id); | ||
1040 | if (!pdev) | ||
1041 | return NULL; | ||
1042 | |||
1043 | if (platform_device_add_resources(pdev, atmel_mci0_resource, | ||
1044 | ARRAY_SIZE(atmel_mci0_resource))) | ||
1045 | goto err_add_resources; | ||
1046 | |||
1047 | select_peripheral(PA(10), PERIPH_A, 0); /* CLK */ | ||
1048 | select_peripheral(PA(11), PERIPH_A, 0); /* CMD */ | ||
1049 | select_peripheral(PA(12), PERIPH_A, 0); /* DATA0 */ | ||
1050 | select_peripheral(PA(13), PERIPH_A, 0); /* DATA1 */ | ||
1051 | select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ | ||
1052 | select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ | ||
1053 | |||
1054 | atmel_mci0_pclk.dev = &pdev->dev; | ||
1055 | |||
1056 | platform_device_add(pdev); | ||
1057 | return pdev; | ||
1058 | |||
1059 | err_add_resources: | ||
1060 | platform_device_put(pdev); | ||
1061 | return NULL; | ||
1062 | } | ||
1063 | |||
1064 | /* -------------------------------------------------------------------- | ||
963 | * LCDC | 1065 | * LCDC |
964 | * -------------------------------------------------------------------- */ | 1066 | * -------------------------------------------------------------------- */ |
965 | static struct atmel_lcdfb_info atmel_lcdfb0_data; | 1067 | static struct atmel_lcdfb_info atmel_lcdfb0_data; |
@@ -1293,6 +1395,105 @@ at32_add_device_ide(unsigned int id, unsigned int extint, | |||
1293 | } | 1395 | } |
1294 | 1396 | ||
1295 | /* -------------------------------------------------------------------- | 1397 | /* -------------------------------------------------------------------- |
1398 | * AC97C | ||
1399 | * -------------------------------------------------------------------- */ | ||
1400 | static struct resource atmel_ac97c0_resource[] __initdata = { | ||
1401 | PBMEM(0xfff02800), | ||
1402 | IRQ(29), | ||
1403 | }; | ||
1404 | static struct clk atmel_ac97c0_pclk = { | ||
1405 | .name = "pclk", | ||
1406 | .parent = &pbb_clk, | ||
1407 | .mode = pbb_clk_mode, | ||
1408 | .get_rate = pbb_clk_get_rate, | ||
1409 | .index = 10, | ||
1410 | }; | ||
1411 | |||
1412 | struct platform_device *__init at32_add_device_ac97c(unsigned int id) | ||
1413 | { | ||
1414 | struct platform_device *pdev; | ||
1415 | |||
1416 | if (id != 0) | ||
1417 | return NULL; | ||
1418 | |||
1419 | pdev = platform_device_alloc("atmel_ac97c", id); | ||
1420 | if (!pdev) | ||
1421 | return NULL; | ||
1422 | |||
1423 | if (platform_device_add_resources(pdev, atmel_ac97c0_resource, | ||
1424 | ARRAY_SIZE(atmel_ac97c0_resource))) | ||
1425 | goto err_add_resources; | ||
1426 | |||
1427 | select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */ | ||
1428 | select_peripheral(PB(21), PERIPH_B, 0); /* SDO */ | ||
1429 | select_peripheral(PB(22), PERIPH_B, 0); /* SDI */ | ||
1430 | select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */ | ||
1431 | |||
1432 | atmel_ac97c0_pclk.dev = &pdev->dev; | ||
1433 | |||
1434 | platform_device_add(pdev); | ||
1435 | return pdev; | ||
1436 | |||
1437 | err_add_resources: | ||
1438 | platform_device_put(pdev); | ||
1439 | return NULL; | ||
1440 | } | ||
1441 | |||
1442 | /* -------------------------------------------------------------------- | ||
1443 | * ABDAC | ||
1444 | * -------------------------------------------------------------------- */ | ||
1445 | static struct resource abdac0_resource[] __initdata = { | ||
1446 | PBMEM(0xfff02000), | ||
1447 | IRQ(27), | ||
1448 | }; | ||
1449 | static struct clk abdac0_pclk = { | ||
1450 | .name = "pclk", | ||
1451 | .parent = &pbb_clk, | ||
1452 | .mode = pbb_clk_mode, | ||
1453 | .get_rate = pbb_clk_get_rate, | ||
1454 | .index = 8, | ||
1455 | }; | ||
1456 | static struct clk abdac0_sample_clk = { | ||
1457 | .name = "sample_clk", | ||
1458 | .mode = genclk_mode, | ||
1459 | .get_rate = genclk_get_rate, | ||
1460 | .set_rate = genclk_set_rate, | ||
1461 | .set_parent = genclk_set_parent, | ||
1462 | .index = 6, | ||
1463 | }; | ||
1464 | |||
1465 | struct platform_device *__init at32_add_device_abdac(unsigned int id) | ||
1466 | { | ||
1467 | struct platform_device *pdev; | ||
1468 | |||
1469 | if (id != 0) | ||
1470 | return NULL; | ||
1471 | |||
1472 | pdev = platform_device_alloc("abdac", id); | ||
1473 | if (!pdev) | ||
1474 | return NULL; | ||
1475 | |||
1476 | if (platform_device_add_resources(pdev, abdac0_resource, | ||
1477 | ARRAY_SIZE(abdac0_resource))) | ||
1478 | goto err_add_resources; | ||
1479 | |||
1480 | select_peripheral(PB(20), PERIPH_A, 0); /* DATA1 */ | ||
1481 | select_peripheral(PB(21), PERIPH_A, 0); /* DATA0 */ | ||
1482 | select_peripheral(PB(22), PERIPH_A, 0); /* DATAN1 */ | ||
1483 | select_peripheral(PB(23), PERIPH_A, 0); /* DATAN0 */ | ||
1484 | |||
1485 | abdac0_pclk.dev = &pdev->dev; | ||
1486 | abdac0_sample_clk.dev = &pdev->dev; | ||
1487 | |||
1488 | platform_device_add(pdev); | ||
1489 | return pdev; | ||
1490 | |||
1491 | err_add_resources: | ||
1492 | platform_device_put(pdev); | ||
1493 | return NULL; | ||
1494 | } | ||
1495 | |||
1496 | /* -------------------------------------------------------------------- | ||
1296 | * GCLK | 1497 | * GCLK |
1297 | * -------------------------------------------------------------------- */ | 1498 | * -------------------------------------------------------------------- */ |
1298 | static struct clk gclk0 = { | 1499 | static struct clk gclk0 = { |
@@ -1355,6 +1556,7 @@ struct clk *at32_clock_list[] = { | |||
1355 | &smc0_mck, | 1556 | &smc0_mck, |
1356 | &pdc_hclk, | 1557 | &pdc_hclk, |
1357 | &pdc_pclk, | 1558 | &pdc_pclk, |
1559 | &dmaca0_hclk, | ||
1358 | &pico_clk, | 1560 | &pico_clk, |
1359 | &pio0_mck, | 1561 | &pio0_mck, |
1360 | &pio1_mck, | 1562 | &pio1_mck, |
@@ -1372,6 +1574,8 @@ struct clk *at32_clock_list[] = { | |||
1372 | &macb1_pclk, | 1574 | &macb1_pclk, |
1373 | &atmel_spi0_spi_clk, | 1575 | &atmel_spi0_spi_clk, |
1374 | &atmel_spi1_spi_clk, | 1576 | &atmel_spi1_spi_clk, |
1577 | &atmel_twi0_pclk, | ||
1578 | &atmel_mci0_pclk, | ||
1375 | &atmel_lcdfb0_hck1, | 1579 | &atmel_lcdfb0_hck1, |
1376 | &atmel_lcdfb0_pixclk, | 1580 | &atmel_lcdfb0_pixclk, |
1377 | &ssc0_pclk, | 1581 | &ssc0_pclk, |
@@ -1379,6 +1583,9 @@ struct clk *at32_clock_list[] = { | |||
1379 | &ssc2_pclk, | 1583 | &ssc2_pclk, |
1380 | &usba0_hclk, | 1584 | &usba0_hclk, |
1381 | &usba0_pclk, | 1585 | &usba0_pclk, |
1586 | &atmel_ac97c0_pclk, | ||
1587 | &abdac0_pclk, | ||
1588 | &abdac0_sample_clk, | ||
1382 | &gclk0, | 1589 | &gclk0, |
1383 | &gclk1, | 1590 | &gclk1, |
1384 | &gclk2, | 1591 | &gclk2, |
@@ -1420,6 +1627,7 @@ void __init at32_clock_init(void) | |||
1420 | genclk_init_parent(&gclk3); | 1627 | genclk_init_parent(&gclk3); |
1421 | genclk_init_parent(&gclk4); | 1628 | genclk_init_parent(&gclk4); |
1422 | genclk_init_parent(&atmel_lcdfb0_pixclk); | 1629 | genclk_init_parent(&atmel_lcdfb0_pixclk); |
1630 | genclk_init_parent(&abdac0_sample_clk); | ||
1423 | 1631 | ||
1424 | /* | 1632 | /* |
1425 | * Turn on all clocks that have at least one user already, and | 1633 | * Turn on all clocks that have at least one user already, and |