aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/mach-at32ap
diff options
context:
space:
mode:
Diffstat (limited to 'arch/avr32/mach-at32ap')
-rw-r--r--arch/avr32/mach-at32ap/at32ap7000.c344
-rw-r--r--arch/avr32/mach-at32ap/extint.c2
-rw-r--r--arch/avr32/mach-at32ap/pm.h4
-rw-r--r--arch/avr32/mach-at32ap/time-tc.c2
4 files changed, 348 insertions, 4 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c
index f6d154ca4d24..a9d9ec081e3d 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
559static struct resource dmaca0_resource[] = {
560 {
561 .start = 0xff200000,
562 .end = 0xff20ffff,
563 .flags = IORESOURCE_MEM,
564 },
565 IRQ(2),
566};
567DEFINE_DEV(dmaca, 0);
568DEV_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 * -------------------------------------------------------------------- */
977static struct resource atmel_twi0_resource[] __initdata = {
978 PBMEM(0xffe00800),
979 IRQ(5),
980};
981static 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
989struct 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
1012err_add_resources:
1013 platform_device_put(pdev);
1014 return NULL;
1015}
1016
1017/* --------------------------------------------------------------------
1018 * MMC
1019 * -------------------------------------------------------------------- */
1020static struct resource atmel_mci0_resource[] __initdata = {
1021 PBMEM(0xfff02400),
1022 IRQ(28),
1023};
1024static 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
1032struct 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
1059err_add_resources:
1060 platform_device_put(pdev);
1061 return NULL;
1062}
1063
1064/* --------------------------------------------------------------------
963 * LCDC 1065 * LCDC
964 * -------------------------------------------------------------------- */ 1066 * -------------------------------------------------------------------- */
965static struct atmel_lcdfb_info atmel_lcdfb0_data; 1067static struct atmel_lcdfb_info atmel_lcdfb0_data;
@@ -1228,6 +1330,241 @@ out_free_pdev:
1228} 1330}
1229 1331
1230/* -------------------------------------------------------------------- 1332/* --------------------------------------------------------------------
1333 * IDE / CompactFlash
1334 * -------------------------------------------------------------------- */
1335static struct resource at32_smc_cs4_resource[] __initdata = {
1336 {
1337 .start = 0x04000000,
1338 .end = 0x07ffffff,
1339 .flags = IORESOURCE_MEM,
1340 },
1341 IRQ(~0UL), /* Magic IRQ will be overridden */
1342};
1343static struct resource at32_smc_cs5_resource[] __initdata = {
1344 {
1345 .start = 0x20000000,
1346 .end = 0x23ffffff,
1347 .flags = IORESOURCE_MEM,
1348 },
1349 IRQ(~0UL), /* Magic IRQ will be overridden */
1350};
1351
1352static int __init at32_init_ide_or_cf(struct platform_device *pdev,
1353 unsigned int cs, unsigned int extint)
1354{
1355 static unsigned int extint_pin_map[4] __initdata = {
1356 GPIO_PIN_PB(25),
1357 GPIO_PIN_PB(26),
1358 GPIO_PIN_PB(27),
1359 GPIO_PIN_PB(28),
1360 };
1361 static bool common_pins_initialized __initdata = false;
1362 unsigned int extint_pin;
1363 int ret;
1364
1365 if (extint >= ARRAY_SIZE(extint_pin_map))
1366 return -EINVAL;
1367 extint_pin = extint_pin_map[extint];
1368
1369 switch (cs) {
1370 case 4:
1371 ret = platform_device_add_resources(pdev,
1372 at32_smc_cs4_resource,
1373 ARRAY_SIZE(at32_smc_cs4_resource));
1374 if (ret)
1375 return ret;
1376
1377 select_peripheral(PE(21), PERIPH_A, 0); /* NCS4 -> OE_N */
1378 set_ebi_sfr_bits(HMATRIX_BIT(CS4A));
1379 break;
1380 case 5:
1381 ret = platform_device_add_resources(pdev,
1382 at32_smc_cs5_resource,
1383 ARRAY_SIZE(at32_smc_cs5_resource));
1384 if (ret)
1385 return ret;
1386
1387 select_peripheral(PE(22), PERIPH_A, 0); /* NCS5 -> OE_N */
1388 set_ebi_sfr_bits(HMATRIX_BIT(CS5A));
1389 break;
1390 default:
1391 return -EINVAL;
1392 }
1393
1394 if (!common_pins_initialized) {
1395 select_peripheral(PE(19), PERIPH_A, 0); /* CFCE1 -> CS0_N */
1396 select_peripheral(PE(20), PERIPH_A, 0); /* CFCE2 -> CS1_N */
1397 select_peripheral(PE(23), PERIPH_A, 0); /* CFRNW -> DIR */
1398 select_peripheral(PE(24), PERIPH_A, 0); /* NWAIT <- IORDY */
1399 common_pins_initialized = true;
1400 }
1401
1402 at32_select_periph(extint_pin, GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH);
1403
1404 pdev->resource[1].start = EIM_IRQ_BASE + extint;
1405 pdev->resource[1].end = pdev->resource[1].start;
1406
1407 return 0;
1408}
1409
1410struct platform_device *__init
1411at32_add_device_ide(unsigned int id, unsigned int extint,
1412 struct ide_platform_data *data)
1413{
1414 struct platform_device *pdev;
1415
1416 pdev = platform_device_alloc("at32_ide", id);
1417 if (!pdev)
1418 goto fail;
1419
1420 if (platform_device_add_data(pdev, data,
1421 sizeof(struct ide_platform_data)))
1422 goto fail;
1423
1424 if (at32_init_ide_or_cf(pdev, data->cs, extint))
1425 goto fail;
1426
1427 platform_device_add(pdev);
1428 return pdev;
1429
1430fail:
1431 platform_device_put(pdev);
1432 return NULL;
1433}
1434
1435struct platform_device *__init
1436at32_add_device_cf(unsigned int id, unsigned int extint,
1437 struct cf_platform_data *data)
1438{
1439 struct platform_device *pdev;
1440
1441 pdev = platform_device_alloc("at32_cf", id);
1442 if (!pdev)
1443 goto fail;
1444
1445 if (platform_device_add_data(pdev, data,
1446 sizeof(struct cf_platform_data)))
1447 goto fail;
1448
1449 if (at32_init_ide_or_cf(pdev, data->cs, extint))
1450 goto fail;
1451
1452 if (data->detect_pin != GPIO_PIN_NONE)
1453 at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH);
1454 if (data->reset_pin != GPIO_PIN_NONE)
1455 at32_select_gpio(data->reset_pin, 0);
1456 if (data->vcc_pin != GPIO_PIN_NONE)
1457 at32_select_gpio(data->vcc_pin, 0);
1458 /* READY is used as extint, so we can't select it as gpio */
1459
1460 platform_device_add(pdev);
1461 return pdev;
1462
1463fail:
1464 platform_device_put(pdev);
1465 return NULL;
1466}
1467
1468/* --------------------------------------------------------------------
1469 * AC97C
1470 * -------------------------------------------------------------------- */
1471static struct resource atmel_ac97c0_resource[] __initdata = {
1472 PBMEM(0xfff02800),
1473 IRQ(29),
1474};
1475static struct clk atmel_ac97c0_pclk = {
1476 .name = "pclk",
1477 .parent = &pbb_clk,
1478 .mode = pbb_clk_mode,
1479 .get_rate = pbb_clk_get_rate,
1480 .index = 10,
1481};
1482
1483struct platform_device *__init at32_add_device_ac97c(unsigned int id)
1484{
1485 struct platform_device *pdev;
1486
1487 if (id != 0)
1488 return NULL;
1489
1490 pdev = platform_device_alloc("atmel_ac97c", id);
1491 if (!pdev)
1492 return NULL;
1493
1494 if (platform_device_add_resources(pdev, atmel_ac97c0_resource,
1495 ARRAY_SIZE(atmel_ac97c0_resource)))
1496 goto err_add_resources;
1497
1498 select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */
1499 select_peripheral(PB(21), PERIPH_B, 0); /* SDO */
1500 select_peripheral(PB(22), PERIPH_B, 0); /* SDI */
1501 select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */
1502
1503 atmel_ac97c0_pclk.dev = &pdev->dev;
1504
1505 platform_device_add(pdev);
1506 return pdev;
1507
1508err_add_resources:
1509 platform_device_put(pdev);
1510 return NULL;
1511}
1512
1513/* --------------------------------------------------------------------
1514 * ABDAC
1515 * -------------------------------------------------------------------- */
1516static struct resource abdac0_resource[] __initdata = {
1517 PBMEM(0xfff02000),
1518 IRQ(27),
1519};
1520static struct clk abdac0_pclk = {
1521 .name = "pclk",
1522 .parent = &pbb_clk,
1523 .mode = pbb_clk_mode,
1524 .get_rate = pbb_clk_get_rate,
1525 .index = 8,
1526};
1527static struct clk abdac0_sample_clk = {
1528 .name = "sample_clk",
1529 .mode = genclk_mode,
1530 .get_rate = genclk_get_rate,
1531 .set_rate = genclk_set_rate,
1532 .set_parent = genclk_set_parent,
1533 .index = 6,
1534};
1535
1536struct platform_device *__init at32_add_device_abdac(unsigned int id)
1537{
1538 struct platform_device *pdev;
1539
1540 if (id != 0)
1541 return NULL;
1542
1543 pdev = platform_device_alloc("abdac", id);
1544 if (!pdev)
1545 return NULL;
1546
1547 if (platform_device_add_resources(pdev, abdac0_resource,
1548 ARRAY_SIZE(abdac0_resource)))
1549 goto err_add_resources;
1550
1551 select_peripheral(PB(20), PERIPH_A, 0); /* DATA1 */
1552 select_peripheral(PB(21), PERIPH_A, 0); /* DATA0 */
1553 select_peripheral(PB(22), PERIPH_A, 0); /* DATAN1 */
1554 select_peripheral(PB(23), PERIPH_A, 0); /* DATAN0 */
1555
1556 abdac0_pclk.dev = &pdev->dev;
1557 abdac0_sample_clk.dev = &pdev->dev;
1558
1559 platform_device_add(pdev);
1560 return pdev;
1561
1562err_add_resources:
1563 platform_device_put(pdev);
1564 return NULL;
1565}
1566
1567/* --------------------------------------------------------------------
1231 * GCLK 1568 * GCLK
1232 * -------------------------------------------------------------------- */ 1569 * -------------------------------------------------------------------- */
1233static struct clk gclk0 = { 1570static struct clk gclk0 = {
@@ -1290,6 +1627,7 @@ struct clk *at32_clock_list[] = {
1290 &smc0_mck, 1627 &smc0_mck,
1291 &pdc_hclk, 1628 &pdc_hclk,
1292 &pdc_pclk, 1629 &pdc_pclk,
1630 &dmaca0_hclk,
1293 &pico_clk, 1631 &pico_clk,
1294 &pio0_mck, 1632 &pio0_mck,
1295 &pio1_mck, 1633 &pio1_mck,
@@ -1307,6 +1645,8 @@ struct clk *at32_clock_list[] = {
1307 &macb1_pclk, 1645 &macb1_pclk,
1308 &atmel_spi0_spi_clk, 1646 &atmel_spi0_spi_clk,
1309 &atmel_spi1_spi_clk, 1647 &atmel_spi1_spi_clk,
1648 &atmel_twi0_pclk,
1649 &atmel_mci0_pclk,
1310 &atmel_lcdfb0_hck1, 1650 &atmel_lcdfb0_hck1,
1311 &atmel_lcdfb0_pixclk, 1651 &atmel_lcdfb0_pixclk,
1312 &ssc0_pclk, 1652 &ssc0_pclk,
@@ -1314,6 +1654,9 @@ struct clk *at32_clock_list[] = {
1314 &ssc2_pclk, 1654 &ssc2_pclk,
1315 &usba0_hclk, 1655 &usba0_hclk,
1316 &usba0_pclk, 1656 &usba0_pclk,
1657 &atmel_ac97c0_pclk,
1658 &abdac0_pclk,
1659 &abdac0_sample_clk,
1317 &gclk0, 1660 &gclk0,
1318 &gclk1, 1661 &gclk1,
1319 &gclk2, 1662 &gclk2,
@@ -1355,6 +1698,7 @@ void __init at32_clock_init(void)
1355 genclk_init_parent(&gclk3); 1698 genclk_init_parent(&gclk3);
1356 genclk_init_parent(&gclk4); 1699 genclk_init_parent(&gclk4);
1357 genclk_init_parent(&atmel_lcdfb0_pixclk); 1700 genclk_init_parent(&atmel_lcdfb0_pixclk);
1701 genclk_init_parent(&abdac0_sample_clk);
1358 1702
1359 /* 1703 /*
1360 * Turn on all clocks that have at least one user already, and 1704 * Turn on all clocks that have at least one user already, and
diff --git a/arch/avr32/mach-at32ap/extint.c b/arch/avr32/mach-at32ap/extint.c
index 8acd01090031..f5bfd4c81fe7 100644
--- a/arch/avr32/mach-at32ap/extint.c
+++ b/arch/avr32/mach-at32ap/extint.c
@@ -142,7 +142,7 @@ static int eic_set_irq_type(unsigned int irq, unsigned int flow_type)
142 return ret; 142 return ret;
143} 143}
144 144
145struct irq_chip eic_chip = { 145static struct irq_chip eic_chip = {
146 .name = "eic", 146 .name = "eic",
147 .ack = eic_ack_irq, 147 .ack = eic_ack_irq,
148 .mask = eic_mask_irq, 148 .mask = eic_mask_irq,
diff --git a/arch/avr32/mach-at32ap/pm.h b/arch/avr32/mach-at32ap/pm.h
index 47efd0d1951f..694d521edc2f 100644
--- a/arch/avr32/mach-at32ap/pm.h
+++ b/arch/avr32/mach-at32ap/pm.h
@@ -113,8 +113,8 @@
113 113
114/* Register access macros */ 114/* Register access macros */
115#define pm_readl(reg) \ 115#define pm_readl(reg) \
116 __raw_readl((void __iomem *)AT32_PM_BASE + PM_##reg) 116 __raw_readl((void __iomem __force *)AT32_PM_BASE + PM_##reg)
117#define pm_writel(reg,value) \ 117#define pm_writel(reg,value) \
118 __raw_writel((value), (void __iomem *)AT32_PM_BASE + PM_##reg) 118 __raw_writel((value), (void __iomem __force *)AT32_PM_BASE + PM_##reg)
119 119
120#endif /* __ARCH_AVR32_MACH_AT32AP_PM_H__ */ 120#endif /* __ARCH_AVR32_MACH_AT32AP_PM_H__ */
diff --git a/arch/avr32/mach-at32ap/time-tc.c b/arch/avr32/mach-at32ap/time-tc.c
index e3070bdd4bb9..10265863c982 100644
--- a/arch/avr32/mach-at32ap/time-tc.c
+++ b/arch/avr32/mach-at32ap/time-tc.c
@@ -79,7 +79,7 @@ static int avr32_timer_calc_div_and_set_jiffies(struct clk *pclk)
79{ 79{
80 unsigned int cycles_max = (clocksource_avr32.mask + 1) / 2; 80 unsigned int cycles_max = (clocksource_avr32.mask + 1) / 2;
81 unsigned int divs[] = { 4, 8, 16, 32 }; 81 unsigned int divs[] = { 4, 8, 16, 32 };
82 int divs_size = sizeof(divs) / sizeof(*divs); 82 int divs_size = ARRAY_SIZE(divs);
83 int i = 0; 83 int i = 0;
84 unsigned long count_hz; 84 unsigned long count_hz;
85 unsigned long shift; 85 unsigned long shift;