diff options
author | Arnd Bergmann <arnd@arndb.de> | 2012-01-07 15:21:04 -0500 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-01-07 15:23:00 -0500 |
commit | 928a11ba36f999436915ea2b1eadf54301f93059 (patch) | |
tree | 8d7cb575d528ddd4b1165e4690401c729c1eb930 /drivers | |
parent | 237c78beb8a988453bac1993d21f025d070a0d8d (diff) | |
parent | 40ba95fdf158713377d47736b1b3a9d75f4f2515 (diff) |
Merge branch 'next/cleanup' into samsung/dt
Conflicts:
arch/arm/mach-exynos/common.c
The common.c file gets changes from rmk/stable-devel (part of
next/cleanup), rmk/restart, samsung/dt and follow-on branches
from the samsung tree.
Pulling it all together here hopefully avoids having to do
even more conflicting merge changesets in this one file. What
a mess!
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ata/pata_at91.c | 6 | ||||
-rw-r--r-- | drivers/ide/at91_ide.c | 2 | ||||
-rw-r--r-- | drivers/media/video/davinci/vpif.h | 1 | ||||
-rw-r--r-- | drivers/media/video/davinci/vpif_capture.h | 2 | ||||
-rw-r--r-- | drivers/media/video/davinci/vpif_display.h | 1 | ||||
-rw-r--r-- | drivers/mmc/host/at91_mci.c | 30 | ||||
-rw-r--r-- | drivers/mtd/nand/atmel_nand.c | 8 | ||||
-rw-r--r-- | drivers/net/ethernet/cadence/at91_ether.c | 3 | ||||
-rw-r--r-- | drivers/net/ethernet/cadence/at91_ether.h | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/cadence/macb.c | 153 | ||||
-rw-r--r-- | drivers/rtc/rtc-at91rm9200.c | 101 | ||||
-rw-r--r-- | drivers/usb/gadget/at91_udc.c | 14 | ||||
-rw-r--r-- | drivers/usb/host/ohci-at91.c | 12 | ||||
-rw-r--r-- | drivers/watchdog/at91sam9_wdt.c | 22 | ||||
-rw-r--r-- | drivers/watchdog/at91sam9_wdt.h | 6 |
15 files changed, 191 insertions, 174 deletions
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c index a76f24a8e5db..5249e6d918a3 100644 --- a/drivers/ata/pata_at91.c +++ b/drivers/ata/pata_at91.c | |||
@@ -360,7 +360,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev) | |||
360 | ap->flags |= ATA_FLAG_SLAVE_POSS; | 360 | ap->flags |= ATA_FLAG_SLAVE_POSS; |
361 | ap->pio_mask = ATA_PIO4; | 361 | ap->pio_mask = ATA_PIO4; |
362 | 362 | ||
363 | if (!irq) { | 363 | if (!gpio_is_valid(irq)) { |
364 | ap->flags |= ATA_FLAG_PIO_POLLING; | 364 | ap->flags |= ATA_FLAG_PIO_POLLING; |
365 | ata_port_desc(ap, "no IRQ, using PIO polling"); | 365 | ata_port_desc(ap, "no IRQ, using PIO polling"); |
366 | } | 366 | } |
@@ -414,8 +414,8 @@ static int __devinit pata_at91_probe(struct platform_device *pdev) | |||
414 | 414 | ||
415 | host->private_data = info; | 415 | host->private_data = info; |
416 | 416 | ||
417 | ret = ata_host_activate(host, irq ? gpio_to_irq(irq) : 0, | 417 | return ata_host_activate(host, gpio_is_valid(irq) ? gpio_to_irq(irq) : 0, |
418 | irq ? ata_sff_interrupt : NULL, | 418 | gpio_is_valid(irq) ? ata_sff_interrupt : NULL, |
419 | irq_flags, &pata_at91_sht); | 419 | irq_flags, &pata_at91_sht); |
420 | 420 | ||
421 | if (!ret) | 421 | if (!ret) |
diff --git a/drivers/ide/at91_ide.c b/drivers/ide/at91_ide.c index 6dede8f366c5..41d415529479 100644 --- a/drivers/ide/at91_ide.c +++ b/drivers/ide/at91_ide.c | |||
@@ -314,7 +314,7 @@ static int __init at91_ide_probe(struct platform_device *pdev) | |||
314 | apply_timings(board->chipselect, 0, ide_timing_find_mode(XFER_PIO_0), 0); | 314 | apply_timings(board->chipselect, 0, ide_timing_find_mode(XFER_PIO_0), 0); |
315 | 315 | ||
316 | /* with GPIO interrupt we have to do quirks in handler */ | 316 | /* with GPIO interrupt we have to do quirks in handler */ |
317 | if (board->irq_pin >= PIN_BASE) | 317 | if (gpio_is_valid(board->irq_pin)) |
318 | host->irq_handler = at91_irq_handler; | 318 | host->irq_handler = at91_irq_handler; |
319 | 319 | ||
320 | host->ports[0]->select_data = board->chipselect; | 320 | host->ports[0]->select_data = board->chipselect; |
diff --git a/drivers/media/video/davinci/vpif.h b/drivers/media/video/davinci/vpif.h index 10550bd93b06..25036cb11bea 100644 --- a/drivers/media/video/davinci/vpif.h +++ b/drivers/media/video/davinci/vpif.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/videodev2.h> | 20 | #include <linux/videodev2.h> |
21 | #include <mach/hardware.h> | 21 | #include <mach/hardware.h> |
22 | #include <mach/dm646x.h> | 22 | #include <mach/dm646x.h> |
23 | #include <media/davinci/vpif_types.h> | ||
23 | 24 | ||
24 | /* Maximum channel allowed */ | 25 | /* Maximum channel allowed */ |
25 | #define VPIF_NUM_CHANNELS (4) | 26 | #define VPIF_NUM_CHANNELS (4) |
diff --git a/drivers/media/video/davinci/vpif_capture.h b/drivers/media/video/davinci/vpif_capture.h index 064550f5ce4a..a693d4ebda55 100644 --- a/drivers/media/video/davinci/vpif_capture.h +++ b/drivers/media/video/davinci/vpif_capture.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <media/v4l2-device.h> | 27 | #include <media/v4l2-device.h> |
28 | #include <media/videobuf-core.h> | 28 | #include <media/videobuf-core.h> |
29 | #include <media/videobuf-dma-contig.h> | 29 | #include <media/videobuf-dma-contig.h> |
30 | #include <mach/dm646x.h> | 30 | #include <media/davinci/vpif_types.h> |
31 | 31 | ||
32 | #include "vpif.h" | 32 | #include "vpif.h" |
33 | 33 | ||
diff --git a/drivers/media/video/davinci/vpif_display.h b/drivers/media/video/davinci/vpif_display.h index 5d1936dafed2..56879d1a0684 100644 --- a/drivers/media/video/davinci/vpif_display.h +++ b/drivers/media/video/davinci/vpif_display.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <media/v4l2-device.h> | 22 | #include <media/v4l2-device.h> |
23 | #include <media/videobuf-core.h> | 23 | #include <media/videobuf-core.h> |
24 | #include <media/videobuf-dma-contig.h> | 24 | #include <media/videobuf-dma-contig.h> |
25 | #include <media/davinci/vpif_types.h> | ||
25 | 26 | ||
26 | #include "vpif.h" | 27 | #include "vpif.h" |
27 | 28 | ||
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index a8b4d2aa18e5..f437c3e6f3aa 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -741,7 +741,7 @@ static void at91_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
741 | at91_mci_write(host, AT91_MCI_MR, (at91_mci_read(host, AT91_MCI_MR) & ~AT91_MCI_CLKDIV) | clkdiv); | 741 | at91_mci_write(host, AT91_MCI_MR, (at91_mci_read(host, AT91_MCI_MR) & ~AT91_MCI_CLKDIV) | clkdiv); |
742 | 742 | ||
743 | /* maybe switch power to the card */ | 743 | /* maybe switch power to the card */ |
744 | if (host->board->vcc_pin) { | 744 | if (gpio_is_valid(host->board->vcc_pin)) { |
745 | switch (ios->power_mode) { | 745 | switch (ios->power_mode) { |
746 | case MMC_POWER_OFF: | 746 | case MMC_POWER_OFF: |
747 | gpio_set_value(host->board->vcc_pin, 0); | 747 | gpio_set_value(host->board->vcc_pin, 0); |
@@ -897,7 +897,7 @@ static int at91_mci_get_ro(struct mmc_host *mmc) | |||
897 | { | 897 | { |
898 | struct at91mci_host *host = mmc_priv(mmc); | 898 | struct at91mci_host *host = mmc_priv(mmc); |
899 | 899 | ||
900 | if (host->board->wp_pin) | 900 | if (gpio_is_valid(host->board->wp_pin)) |
901 | return !!gpio_get_value(host->board->wp_pin); | 901 | return !!gpio_get_value(host->board->wp_pin); |
902 | /* | 902 | /* |
903 | * Board doesn't support read only detection; let the mmc core | 903 | * Board doesn't support read only detection; let the mmc core |
@@ -991,21 +991,21 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
991 | * Reserve GPIOs ... board init code makes sure these pins are set | 991 | * Reserve GPIOs ... board init code makes sure these pins are set |
992 | * up as GPIOs with the right direction (input, except for vcc) | 992 | * up as GPIOs with the right direction (input, except for vcc) |
993 | */ | 993 | */ |
994 | if (host->board->det_pin) { | 994 | if (gpio_is_valid(host->board->det_pin)) { |
995 | ret = gpio_request(host->board->det_pin, "mmc_detect"); | 995 | ret = gpio_request(host->board->det_pin, "mmc_detect"); |
996 | if (ret < 0) { | 996 | if (ret < 0) { |
997 | dev_dbg(&pdev->dev, "couldn't claim card detect pin\n"); | 997 | dev_dbg(&pdev->dev, "couldn't claim card detect pin\n"); |
998 | goto fail4b; | 998 | goto fail4b; |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | if (host->board->wp_pin) { | 1001 | if (gpio_is_valid(host->board->wp_pin)) { |
1002 | ret = gpio_request(host->board->wp_pin, "mmc_wp"); | 1002 | ret = gpio_request(host->board->wp_pin, "mmc_wp"); |
1003 | if (ret < 0) { | 1003 | if (ret < 0) { |
1004 | dev_dbg(&pdev->dev, "couldn't claim wp sense pin\n"); | 1004 | dev_dbg(&pdev->dev, "couldn't claim wp sense pin\n"); |
1005 | goto fail4; | 1005 | goto fail4; |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | if (host->board->vcc_pin) { | 1008 | if (gpio_is_valid(host->board->vcc_pin)) { |
1009 | ret = gpio_request(host->board->vcc_pin, "mmc_vcc"); | 1009 | ret = gpio_request(host->board->vcc_pin, "mmc_vcc"); |
1010 | if (ret < 0) { | 1010 | if (ret < 0) { |
1011 | dev_dbg(&pdev->dev, "couldn't claim vcc switch pin\n"); | 1011 | dev_dbg(&pdev->dev, "couldn't claim vcc switch pin\n"); |
@@ -1057,7 +1057,7 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1057 | /* | 1057 | /* |
1058 | * Add host to MMC layer | 1058 | * Add host to MMC layer |
1059 | */ | 1059 | */ |
1060 | if (host->board->det_pin) { | 1060 | if (gpio_is_valid(host->board->det_pin)) { |
1061 | host->present = !gpio_get_value(host->board->det_pin); | 1061 | host->present = !gpio_get_value(host->board->det_pin); |
1062 | } | 1062 | } |
1063 | else | 1063 | else |
@@ -1068,7 +1068,7 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1068 | /* | 1068 | /* |
1069 | * monitor card insertion/removal if we can | 1069 | * monitor card insertion/removal if we can |
1070 | */ | 1070 | */ |
1071 | if (host->board->det_pin) { | 1071 | if (gpio_is_valid(host->board->det_pin)) { |
1072 | ret = request_irq(gpio_to_irq(host->board->det_pin), | 1072 | ret = request_irq(gpio_to_irq(host->board->det_pin), |
1073 | at91_mmc_det_irq, 0, mmc_hostname(mmc), host); | 1073 | at91_mmc_det_irq, 0, mmc_hostname(mmc), host); |
1074 | if (ret) | 1074 | if (ret) |
@@ -1087,13 +1087,13 @@ fail0: | |||
1087 | fail1: | 1087 | fail1: |
1088 | clk_put(host->mci_clk); | 1088 | clk_put(host->mci_clk); |
1089 | fail2: | 1089 | fail2: |
1090 | if (host->board->vcc_pin) | 1090 | if (gpio_is_valid(host->board->vcc_pin)) |
1091 | gpio_free(host->board->vcc_pin); | 1091 | gpio_free(host->board->vcc_pin); |
1092 | fail3: | 1092 | fail3: |
1093 | if (host->board->wp_pin) | 1093 | if (gpio_is_valid(host->board->wp_pin)) |
1094 | gpio_free(host->board->wp_pin); | 1094 | gpio_free(host->board->wp_pin); |
1095 | fail4: | 1095 | fail4: |
1096 | if (host->board->det_pin) | 1096 | if (gpio_is_valid(host->board->det_pin)) |
1097 | gpio_free(host->board->det_pin); | 1097 | gpio_free(host->board->det_pin); |
1098 | fail4b: | 1098 | fail4b: |
1099 | if (host->buffer) | 1099 | if (host->buffer) |
@@ -1125,7 +1125,7 @@ static int __exit at91_mci_remove(struct platform_device *pdev) | |||
1125 | dma_free_coherent(&pdev->dev, MCI_BUFSIZE, | 1125 | dma_free_coherent(&pdev->dev, MCI_BUFSIZE, |
1126 | host->buffer, host->physical_address); | 1126 | host->buffer, host->physical_address); |
1127 | 1127 | ||
1128 | if (host->board->det_pin) { | 1128 | if (gpio_is_valid(host->board->det_pin)) { |
1129 | if (device_can_wakeup(&pdev->dev)) | 1129 | if (device_can_wakeup(&pdev->dev)) |
1130 | free_irq(gpio_to_irq(host->board->det_pin), host); | 1130 | free_irq(gpio_to_irq(host->board->det_pin), host); |
1131 | device_init_wakeup(&pdev->dev, 0); | 1131 | device_init_wakeup(&pdev->dev, 0); |
@@ -1140,9 +1140,9 @@ static int __exit at91_mci_remove(struct platform_device *pdev) | |||
1140 | clk_disable(host->mci_clk); /* Disable the peripheral clock */ | 1140 | clk_disable(host->mci_clk); /* Disable the peripheral clock */ |
1141 | clk_put(host->mci_clk); | 1141 | clk_put(host->mci_clk); |
1142 | 1142 | ||
1143 | if (host->board->vcc_pin) | 1143 | if (gpio_is_valid(host->board->vcc_pin)) |
1144 | gpio_free(host->board->vcc_pin); | 1144 | gpio_free(host->board->vcc_pin); |
1145 | if (host->board->wp_pin) | 1145 | if (gpio_is_valid(host->board->wp_pin)) |
1146 | gpio_free(host->board->wp_pin); | 1146 | gpio_free(host->board->wp_pin); |
1147 | 1147 | ||
1148 | iounmap(host->baseaddr); | 1148 | iounmap(host->baseaddr); |
@@ -1163,7 +1163,7 @@ static int at91_mci_suspend(struct platform_device *pdev, pm_message_t state) | |||
1163 | struct at91mci_host *host = mmc_priv(mmc); | 1163 | struct at91mci_host *host = mmc_priv(mmc); |
1164 | int ret = 0; | 1164 | int ret = 0; |
1165 | 1165 | ||
1166 | if (host->board->det_pin && device_may_wakeup(&pdev->dev)) | 1166 | if (gpio_is_valid(host->board->det_pin) && device_may_wakeup(&pdev->dev)) |
1167 | enable_irq_wake(host->board->det_pin); | 1167 | enable_irq_wake(host->board->det_pin); |
1168 | 1168 | ||
1169 | if (mmc) | 1169 | if (mmc) |
@@ -1178,7 +1178,7 @@ static int at91_mci_resume(struct platform_device *pdev) | |||
1178 | struct at91mci_host *host = mmc_priv(mmc); | 1178 | struct at91mci_host *host = mmc_priv(mmc); |
1179 | int ret = 0; | 1179 | int ret = 0; |
1180 | 1180 | ||
1181 | if (host->board->det_pin && device_may_wakeup(&pdev->dev)) | 1181 | if (gpio_is_valid(host->board->det_pin) && device_may_wakeup(&pdev->dev)) |
1182 | disable_irq_wake(host->board->det_pin); | 1182 | disable_irq_wake(host->board->det_pin); |
1183 | 1183 | ||
1184 | if (mmc) | 1184 | if (mmc) |
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index 23e5d77c39fc..4dd056e2e16a 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c | |||
@@ -113,7 +113,7 @@ static int cpu_has_dma(void) | |||
113 | */ | 113 | */ |
114 | static void atmel_nand_enable(struct atmel_nand_host *host) | 114 | static void atmel_nand_enable(struct atmel_nand_host *host) |
115 | { | 115 | { |
116 | if (host->board->enable_pin) | 116 | if (gpio_is_valid(host->board->enable_pin)) |
117 | gpio_set_value(host->board->enable_pin, 0); | 117 | gpio_set_value(host->board->enable_pin, 0); |
118 | } | 118 | } |
119 | 119 | ||
@@ -122,7 +122,7 @@ static void atmel_nand_enable(struct atmel_nand_host *host) | |||
122 | */ | 122 | */ |
123 | static void atmel_nand_disable(struct atmel_nand_host *host) | 123 | static void atmel_nand_disable(struct atmel_nand_host *host) |
124 | { | 124 | { |
125 | if (host->board->enable_pin) | 125 | if (gpio_is_valid(host->board->enable_pin)) |
126 | gpio_set_value(host->board->enable_pin, 1); | 126 | gpio_set_value(host->board->enable_pin, 1); |
127 | } | 127 | } |
128 | 128 | ||
@@ -492,7 +492,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
492 | nand_chip->IO_ADDR_W = host->io_base; | 492 | nand_chip->IO_ADDR_W = host->io_base; |
493 | nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; | 493 | nand_chip->cmd_ctrl = atmel_nand_cmd_ctrl; |
494 | 494 | ||
495 | if (host->board->rdy_pin) | 495 | if (gpio_is_valid(host->board->rdy_pin)) |
496 | nand_chip->dev_ready = atmel_nand_device_ready; | 496 | nand_chip->dev_ready = atmel_nand_device_ready; |
497 | 497 | ||
498 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 498 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
@@ -530,7 +530,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev) | |||
530 | platform_set_drvdata(pdev, host); | 530 | platform_set_drvdata(pdev, host); |
531 | atmel_nand_enable(host); | 531 | atmel_nand_enable(host); |
532 | 532 | ||
533 | if (host->board->det_pin) { | 533 | if (gpio_is_valid(host->board->det_pin)) { |
534 | if (gpio_get_value(host->board->det_pin)) { | 534 | if (gpio_get_value(host->board->det_pin)) { |
535 | printk(KERN_INFO "No SmartMedia card inserted.\n"); | 535 | printk(KERN_INFO "No SmartMedia card inserted.\n"); |
536 | res = -ENXIO; | 536 | res = -ENXIO; |
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c index 56624d303487..dfeb46cb3f74 100644 --- a/drivers/net/ethernet/cadence/at91_ether.c +++ b/drivers/net/ethernet/cadence/at91_ether.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/skbuff.h> | 26 | #include <linux/skbuff.h> |
27 | #include <linux/dma-mapping.h> | 27 | #include <linux/dma-mapping.h> |
28 | #include <linux/ethtool.h> | 28 | #include <linux/ethtool.h> |
29 | #include <linux/platform_data/macb.h> | ||
29 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
30 | #include <linux/clk.h> | 31 | #include <linux/clk.h> |
31 | #include <linux/gfp.h> | 32 | #include <linux/gfp.h> |
@@ -984,7 +985,7 @@ static const struct net_device_ops at91ether_netdev_ops = { | |||
984 | static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, | 985 | static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, |
985 | struct platform_device *pdev, struct clk *ether_clk) | 986 | struct platform_device *pdev, struct clk *ether_clk) |
986 | { | 987 | { |
987 | struct at91_eth_data *board_data = pdev->dev.platform_data; | 988 | struct macb_platform_data *board_data = pdev->dev.platform_data; |
988 | struct net_device *dev; | 989 | struct net_device *dev; |
989 | struct at91_private *lp; | 990 | struct at91_private *lp; |
990 | unsigned int val; | 991 | unsigned int val; |
diff --git a/drivers/net/ethernet/cadence/at91_ether.h b/drivers/net/ethernet/cadence/at91_ether.h index 353f4dab62be..3725fbb0defe 100644 --- a/drivers/net/ethernet/cadence/at91_ether.h +++ b/drivers/net/ethernet/cadence/at91_ether.h | |||
@@ -85,7 +85,9 @@ struct recv_desc_bufs | |||
85 | struct at91_private | 85 | struct at91_private |
86 | { | 86 | { |
87 | struct mii_if_info mii; /* ethtool support */ | 87 | struct mii_if_info mii; /* ethtool support */ |
88 | struct at91_eth_data board_data; /* board-specific configuration */ | 88 | struct macb_platform_data board_data; /* board-specific |
89 | * configuration (shared with | ||
90 | * macb for common data */ | ||
89 | struct clk *ether_clk; /* clock */ | 91 | struct clk *ether_clk; /* clock */ |
90 | 92 | ||
91 | /* PHY */ | 93 | /* PHY */ |
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index a437b46e5490..aa1d597091a8 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
11 | #include <linux/clk.h> | 12 | #include <linux/clk.h> |
12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
13 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
@@ -19,12 +20,10 @@ | |||
19 | #include <linux/netdevice.h> | 20 | #include <linux/netdevice.h> |
20 | #include <linux/etherdevice.h> | 21 | #include <linux/etherdevice.h> |
21 | #include <linux/dma-mapping.h> | 22 | #include <linux/dma-mapping.h> |
23 | #include <linux/platform_data/macb.h> | ||
22 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
23 | #include <linux/phy.h> | 25 | #include <linux/phy.h> |
24 | 26 | ||
25 | #include <mach/board.h> | ||
26 | #include <mach/cpu.h> | ||
27 | |||
28 | #include "macb.h" | 27 | #include "macb.h" |
29 | 28 | ||
30 | #define RX_BUFFER_SIZE 128 | 29 | #define RX_BUFFER_SIZE 128 |
@@ -84,7 +83,7 @@ static void __init macb_get_hwaddr(struct macb *bp) | |||
84 | if (is_valid_ether_addr(addr)) { | 83 | if (is_valid_ether_addr(addr)) { |
85 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); | 84 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); |
86 | } else { | 85 | } else { |
87 | dev_info(&bp->pdev->dev, "invalid hw address, using random\n"); | 86 | netdev_info(bp->dev, "invalid hw address, using random\n"); |
88 | random_ether_addr(bp->dev->dev_addr); | 87 | random_ether_addr(bp->dev->dev_addr); |
89 | } | 88 | } |
90 | } | 89 | } |
@@ -178,11 +177,12 @@ static void macb_handle_link_change(struct net_device *dev) | |||
178 | 177 | ||
179 | if (status_change) { | 178 | if (status_change) { |
180 | if (phydev->link) | 179 | if (phydev->link) |
181 | printk(KERN_INFO "%s: link up (%d/%s)\n", | 180 | netdev_info(dev, "link up (%d/%s)\n", |
182 | dev->name, phydev->speed, | 181 | phydev->speed, |
183 | DUPLEX_FULL == phydev->duplex ? "Full":"Half"); | 182 | phydev->duplex == DUPLEX_FULL ? |
183 | "Full" : "Half"); | ||
184 | else | 184 | else |
185 | printk(KERN_INFO "%s: link down\n", dev->name); | 185 | netdev_info(dev, "link down\n"); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
@@ -191,12 +191,12 @@ static int macb_mii_probe(struct net_device *dev) | |||
191 | { | 191 | { |
192 | struct macb *bp = netdev_priv(dev); | 192 | struct macb *bp = netdev_priv(dev); |
193 | struct phy_device *phydev; | 193 | struct phy_device *phydev; |
194 | struct eth_platform_data *pdata; | 194 | struct macb_platform_data *pdata; |
195 | int ret; | 195 | int ret; |
196 | 196 | ||
197 | phydev = phy_find_first(bp->mii_bus); | 197 | phydev = phy_find_first(bp->mii_bus); |
198 | if (!phydev) { | 198 | if (!phydev) { |
199 | printk (KERN_ERR "%s: no PHY found\n", dev->name); | 199 | netdev_err(dev, "no PHY found\n"); |
200 | return -1; | 200 | return -1; |
201 | } | 201 | } |
202 | 202 | ||
@@ -209,7 +209,7 @@ static int macb_mii_probe(struct net_device *dev) | |||
209 | PHY_INTERFACE_MODE_RMII : | 209 | PHY_INTERFACE_MODE_RMII : |
210 | PHY_INTERFACE_MODE_MII); | 210 | PHY_INTERFACE_MODE_MII); |
211 | if (ret) { | 211 | if (ret) { |
212 | printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); | 212 | netdev_err(dev, "Could not attach to PHY\n"); |
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | 215 | ||
@@ -228,7 +228,7 @@ static int macb_mii_probe(struct net_device *dev) | |||
228 | 228 | ||
229 | static int macb_mii_init(struct macb *bp) | 229 | static int macb_mii_init(struct macb *bp) |
230 | { | 230 | { |
231 | struct eth_platform_data *pdata; | 231 | struct macb_platform_data *pdata; |
232 | int err = -ENXIO, i; | 232 | int err = -ENXIO, i; |
233 | 233 | ||
234 | /* Enable management port */ | 234 | /* Enable management port */ |
@@ -303,14 +303,13 @@ static void macb_tx(struct macb *bp) | |||
303 | status = macb_readl(bp, TSR); | 303 | status = macb_readl(bp, TSR); |
304 | macb_writel(bp, TSR, status); | 304 | macb_writel(bp, TSR, status); |
305 | 305 | ||
306 | dev_dbg(&bp->pdev->dev, "macb_tx status = %02lx\n", | 306 | netdev_dbg(bp->dev, "macb_tx status = %02lx\n", (unsigned long)status); |
307 | (unsigned long)status); | ||
308 | 307 | ||
309 | if (status & (MACB_BIT(UND) | MACB_BIT(TSR_RLE))) { | 308 | if (status & (MACB_BIT(UND) | MACB_BIT(TSR_RLE))) { |
310 | int i; | 309 | int i; |
311 | printk(KERN_ERR "%s: TX %s, resetting buffers\n", | 310 | netdev_err(bp->dev, "TX %s, resetting buffers\n", |
312 | bp->dev->name, status & MACB_BIT(UND) ? | 311 | status & MACB_BIT(UND) ? |
313 | "underrun" : "retry limit exceeded"); | 312 | "underrun" : "retry limit exceeded"); |
314 | 313 | ||
315 | /* Transfer ongoing, disable transmitter, to avoid confusion */ | 314 | /* Transfer ongoing, disable transmitter, to avoid confusion */ |
316 | if (status & MACB_BIT(TGO)) | 315 | if (status & MACB_BIT(TGO)) |
@@ -369,8 +368,8 @@ static void macb_tx(struct macb *bp) | |||
369 | if (!(bufstat & MACB_BIT(TX_USED))) | 368 | if (!(bufstat & MACB_BIT(TX_USED))) |
370 | break; | 369 | break; |
371 | 370 | ||
372 | dev_dbg(&bp->pdev->dev, "skb %u (data %p) TX complete\n", | 371 | netdev_dbg(bp->dev, "skb %u (data %p) TX complete\n", |
373 | tail, skb->data); | 372 | tail, skb->data); |
374 | dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len, | 373 | dma_unmap_single(&bp->pdev->dev, rp->mapping, skb->len, |
375 | DMA_TO_DEVICE); | 374 | DMA_TO_DEVICE); |
376 | bp->stats.tx_packets++; | 375 | bp->stats.tx_packets++; |
@@ -395,8 +394,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag, | |||
395 | 394 | ||
396 | len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl); | 395 | len = MACB_BFEXT(RX_FRMLEN, bp->rx_ring[last_frag].ctrl); |
397 | 396 | ||
398 | dev_dbg(&bp->pdev->dev, "macb_rx_frame frags %u - %u (len %u)\n", | 397 | netdev_dbg(bp->dev, "macb_rx_frame frags %u - %u (len %u)\n", |
399 | first_frag, last_frag, len); | 398 | first_frag, last_frag, len); |
400 | 399 | ||
401 | skb = dev_alloc_skb(len + RX_OFFSET); | 400 | skb = dev_alloc_skb(len + RX_OFFSET); |
402 | if (!skb) { | 401 | if (!skb) { |
@@ -437,8 +436,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag, | |||
437 | 436 | ||
438 | bp->stats.rx_packets++; | 437 | bp->stats.rx_packets++; |
439 | bp->stats.rx_bytes += len; | 438 | bp->stats.rx_bytes += len; |
440 | dev_dbg(&bp->pdev->dev, "received skb of length %u, csum: %08x\n", | 439 | netdev_dbg(bp->dev, "received skb of length %u, csum: %08x\n", |
441 | skb->len, skb->csum); | 440 | skb->len, skb->csum); |
442 | netif_receive_skb(skb); | 441 | netif_receive_skb(skb); |
443 | 442 | ||
444 | return 0; | 443 | return 0; |
@@ -515,8 +514,8 @@ static int macb_poll(struct napi_struct *napi, int budget) | |||
515 | 514 | ||
516 | work_done = 0; | 515 | work_done = 0; |
517 | 516 | ||
518 | dev_dbg(&bp->pdev->dev, "poll: status = %08lx, budget = %d\n", | 517 | netdev_dbg(bp->dev, "poll: status = %08lx, budget = %d\n", |
519 | (unsigned long)status, budget); | 518 | (unsigned long)status, budget); |
520 | 519 | ||
521 | work_done = macb_rx(bp, budget); | 520 | work_done = macb_rx(bp, budget); |
522 | if (work_done < budget) { | 521 | if (work_done < budget) { |
@@ -565,8 +564,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) | |||
565 | macb_writel(bp, IDR, MACB_RX_INT_FLAGS); | 564 | macb_writel(bp, IDR, MACB_RX_INT_FLAGS); |
566 | 565 | ||
567 | if (napi_schedule_prep(&bp->napi)) { | 566 | if (napi_schedule_prep(&bp->napi)) { |
568 | dev_dbg(&bp->pdev->dev, | 567 | netdev_dbg(bp->dev, "scheduling RX softirq\n"); |
569 | "scheduling RX softirq\n"); | ||
570 | __napi_schedule(&bp->napi); | 568 | __napi_schedule(&bp->napi); |
571 | } | 569 | } |
572 | } | 570 | } |
@@ -587,11 +585,11 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) | |||
587 | 585 | ||
588 | if (status & MACB_BIT(HRESP)) { | 586 | if (status & MACB_BIT(HRESP)) { |
589 | /* | 587 | /* |
590 | * TODO: Reset the hardware, and maybe move the printk | 588 | * TODO: Reset the hardware, and maybe move the |
591 | * to a lower-priority context as well (work queue?) | 589 | * netdev_err to a lower-priority context as well |
590 | * (work queue?) | ||
592 | */ | 591 | */ |
593 | printk(KERN_ERR "%s: DMA bus error: HRESP not OK\n", | 592 | netdev_err(dev, "DMA bus error: HRESP not OK\n"); |
594 | dev->name); | ||
595 | } | 593 | } |
596 | 594 | ||
597 | status = macb_readl(bp, ISR); | 595 | status = macb_readl(bp, ISR); |
@@ -626,16 +624,12 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
626 | unsigned long flags; | 624 | unsigned long flags; |
627 | 625 | ||
628 | #ifdef DEBUG | 626 | #ifdef DEBUG |
629 | int i; | 627 | netdev_dbg(bp->dev, |
630 | dev_dbg(&bp->pdev->dev, | 628 | "start_xmit: len %u head %p data %p tail %p end %p\n", |
631 | "start_xmit: len %u head %p data %p tail %p end %p\n", | 629 | skb->len, skb->head, skb->data, |
632 | skb->len, skb->head, skb->data, | 630 | skb_tail_pointer(skb), skb_end_pointer(skb)); |
633 | skb_tail_pointer(skb), skb_end_pointer(skb)); | 631 | print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_OFFSET, 16, 1, |
634 | dev_dbg(&bp->pdev->dev, | 632 | skb->data, 16, true); |
635 | "data:"); | ||
636 | for (i = 0; i < 16; i++) | ||
637 | printk(" %02x", (unsigned int)skb->data[i]); | ||
638 | printk("\n"); | ||
639 | #endif | 633 | #endif |
640 | 634 | ||
641 | len = skb->len; | 635 | len = skb->len; |
@@ -645,21 +639,20 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
645 | if (TX_BUFFS_AVAIL(bp) < 1) { | 639 | if (TX_BUFFS_AVAIL(bp) < 1) { |
646 | netif_stop_queue(dev); | 640 | netif_stop_queue(dev); |
647 | spin_unlock_irqrestore(&bp->lock, flags); | 641 | spin_unlock_irqrestore(&bp->lock, flags); |
648 | dev_err(&bp->pdev->dev, | 642 | netdev_err(bp->dev, "BUG! Tx Ring full when queue awake!\n"); |
649 | "BUG! Tx Ring full when queue awake!\n"); | 643 | netdev_dbg(bp->dev, "tx_head = %u, tx_tail = %u\n", |
650 | dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n", | 644 | bp->tx_head, bp->tx_tail); |
651 | bp->tx_head, bp->tx_tail); | ||
652 | return NETDEV_TX_BUSY; | 645 | return NETDEV_TX_BUSY; |
653 | } | 646 | } |
654 | 647 | ||
655 | entry = bp->tx_head; | 648 | entry = bp->tx_head; |
656 | dev_dbg(&bp->pdev->dev, "Allocated ring entry %u\n", entry); | 649 | netdev_dbg(bp->dev, "Allocated ring entry %u\n", entry); |
657 | mapping = dma_map_single(&bp->pdev->dev, skb->data, | 650 | mapping = dma_map_single(&bp->pdev->dev, skb->data, |
658 | len, DMA_TO_DEVICE); | 651 | len, DMA_TO_DEVICE); |
659 | bp->tx_skb[entry].skb = skb; | 652 | bp->tx_skb[entry].skb = skb; |
660 | bp->tx_skb[entry].mapping = mapping; | 653 | bp->tx_skb[entry].mapping = mapping; |
661 | dev_dbg(&bp->pdev->dev, "Mapped skb data %p to DMA addr %08lx\n", | 654 | netdev_dbg(bp->dev, "Mapped skb data %p to DMA addr %08lx\n", |
662 | skb->data, (unsigned long)mapping); | 655 | skb->data, (unsigned long)mapping); |
663 | 656 | ||
664 | ctrl = MACB_BF(TX_FRMLEN, len); | 657 | ctrl = MACB_BF(TX_FRMLEN, len); |
665 | ctrl |= MACB_BIT(TX_LAST); | 658 | ctrl |= MACB_BIT(TX_LAST); |
@@ -723,27 +716,27 @@ static int macb_alloc_consistent(struct macb *bp) | |||
723 | &bp->rx_ring_dma, GFP_KERNEL); | 716 | &bp->rx_ring_dma, GFP_KERNEL); |
724 | if (!bp->rx_ring) | 717 | if (!bp->rx_ring) |
725 | goto out_err; | 718 | goto out_err; |
726 | dev_dbg(&bp->pdev->dev, | 719 | netdev_dbg(bp->dev, |
727 | "Allocated RX ring of %d bytes at %08lx (mapped %p)\n", | 720 | "Allocated RX ring of %d bytes at %08lx (mapped %p)\n", |
728 | size, (unsigned long)bp->rx_ring_dma, bp->rx_ring); | 721 | size, (unsigned long)bp->rx_ring_dma, bp->rx_ring); |
729 | 722 | ||
730 | size = TX_RING_BYTES; | 723 | size = TX_RING_BYTES; |
731 | bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size, | 724 | bp->tx_ring = dma_alloc_coherent(&bp->pdev->dev, size, |
732 | &bp->tx_ring_dma, GFP_KERNEL); | 725 | &bp->tx_ring_dma, GFP_KERNEL); |
733 | if (!bp->tx_ring) | 726 | if (!bp->tx_ring) |
734 | goto out_err; | 727 | goto out_err; |
735 | dev_dbg(&bp->pdev->dev, | 728 | netdev_dbg(bp->dev, |
736 | "Allocated TX ring of %d bytes at %08lx (mapped %p)\n", | 729 | "Allocated TX ring of %d bytes at %08lx (mapped %p)\n", |
737 | size, (unsigned long)bp->tx_ring_dma, bp->tx_ring); | 730 | size, (unsigned long)bp->tx_ring_dma, bp->tx_ring); |
738 | 731 | ||
739 | size = RX_RING_SIZE * RX_BUFFER_SIZE; | 732 | size = RX_RING_SIZE * RX_BUFFER_SIZE; |
740 | bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size, | 733 | bp->rx_buffers = dma_alloc_coherent(&bp->pdev->dev, size, |
741 | &bp->rx_buffers_dma, GFP_KERNEL); | 734 | &bp->rx_buffers_dma, GFP_KERNEL); |
742 | if (!bp->rx_buffers) | 735 | if (!bp->rx_buffers) |
743 | goto out_err; | 736 | goto out_err; |
744 | dev_dbg(&bp->pdev->dev, | 737 | netdev_dbg(bp->dev, |
745 | "Allocated RX buffers of %d bytes at %08lx (mapped %p)\n", | 738 | "Allocated RX buffers of %d bytes at %08lx (mapped %p)\n", |
746 | size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers); | 739 | size, (unsigned long)bp->rx_buffers_dma, bp->rx_buffers); |
747 | 740 | ||
748 | return 0; | 741 | return 0; |
749 | 742 | ||
@@ -954,7 +947,7 @@ static int macb_open(struct net_device *dev) | |||
954 | struct macb *bp = netdev_priv(dev); | 947 | struct macb *bp = netdev_priv(dev); |
955 | int err; | 948 | int err; |
956 | 949 | ||
957 | dev_dbg(&bp->pdev->dev, "open\n"); | 950 | netdev_dbg(bp->dev, "open\n"); |
958 | 951 | ||
959 | /* if the phy is not yet register, retry later*/ | 952 | /* if the phy is not yet register, retry later*/ |
960 | if (!bp->phy_dev) | 953 | if (!bp->phy_dev) |
@@ -965,9 +958,8 @@ static int macb_open(struct net_device *dev) | |||
965 | 958 | ||
966 | err = macb_alloc_consistent(bp); | 959 | err = macb_alloc_consistent(bp); |
967 | if (err) { | 960 | if (err) { |
968 | printk(KERN_ERR | 961 | netdev_err(dev, "Unable to allocate DMA memory (error %d)\n", |
969 | "%s: Unable to allocate DMA memory (error %d)\n", | 962 | err); |
970 | dev->name, err); | ||
971 | return err; | 963 | return err; |
972 | } | 964 | } |
973 | 965 | ||
@@ -1119,7 +1111,7 @@ static const struct net_device_ops macb_netdev_ops = { | |||
1119 | 1111 | ||
1120 | static int __init macb_probe(struct platform_device *pdev) | 1112 | static int __init macb_probe(struct platform_device *pdev) |
1121 | { | 1113 | { |
1122 | struct eth_platform_data *pdata; | 1114 | struct macb_platform_data *pdata; |
1123 | struct resource *regs; | 1115 | struct resource *regs; |
1124 | struct net_device *dev; | 1116 | struct net_device *dev; |
1125 | struct macb *bp; | 1117 | struct macb *bp; |
@@ -1152,28 +1144,19 @@ static int __init macb_probe(struct platform_device *pdev) | |||
1152 | 1144 | ||
1153 | spin_lock_init(&bp->lock); | 1145 | spin_lock_init(&bp->lock); |
1154 | 1146 | ||
1155 | #if defined(CONFIG_ARCH_AT91) | 1147 | bp->pclk = clk_get(&pdev->dev, "pclk"); |
1156 | bp->pclk = clk_get(&pdev->dev, "macb_clk"); | ||
1157 | if (IS_ERR(bp->pclk)) { | 1148 | if (IS_ERR(bp->pclk)) { |
1158 | dev_err(&pdev->dev, "failed to get macb_clk\n"); | 1149 | dev_err(&pdev->dev, "failed to get macb_clk\n"); |
1159 | goto err_out_free_dev; | 1150 | goto err_out_free_dev; |
1160 | } | 1151 | } |
1161 | clk_enable(bp->pclk); | 1152 | clk_enable(bp->pclk); |
1162 | #else | 1153 | |
1163 | bp->pclk = clk_get(&pdev->dev, "pclk"); | ||
1164 | if (IS_ERR(bp->pclk)) { | ||
1165 | dev_err(&pdev->dev, "failed to get pclk\n"); | ||
1166 | goto err_out_free_dev; | ||
1167 | } | ||
1168 | bp->hclk = clk_get(&pdev->dev, "hclk"); | 1154 | bp->hclk = clk_get(&pdev->dev, "hclk"); |
1169 | if (IS_ERR(bp->hclk)) { | 1155 | if (IS_ERR(bp->hclk)) { |
1170 | dev_err(&pdev->dev, "failed to get hclk\n"); | 1156 | dev_err(&pdev->dev, "failed to get hclk\n"); |
1171 | goto err_out_put_pclk; | 1157 | goto err_out_put_pclk; |
1172 | } | 1158 | } |
1173 | |||
1174 | clk_enable(bp->pclk); | ||
1175 | clk_enable(bp->hclk); | 1159 | clk_enable(bp->hclk); |
1176 | #endif | ||
1177 | 1160 | ||
1178 | bp->regs = ioremap(regs->start, resource_size(regs)); | 1161 | bp->regs = ioremap(regs->start, resource_size(regs)); |
1179 | if (!bp->regs) { | 1162 | if (!bp->regs) { |
@@ -1185,9 +1168,8 @@ static int __init macb_probe(struct platform_device *pdev) | |||
1185 | dev->irq = platform_get_irq(pdev, 0); | 1168 | dev->irq = platform_get_irq(pdev, 0); |
1186 | err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev); | 1169 | err = request_irq(dev->irq, macb_interrupt, 0, dev->name, dev); |
1187 | if (err) { | 1170 | if (err) { |
1188 | printk(KERN_ERR | 1171 | dev_err(&pdev->dev, "Unable to request IRQ %d (error %d)\n", |
1189 | "%s: Unable to request IRQ %d (error %d)\n", | 1172 | dev->irq, err); |
1190 | dev->name, dev->irq, err); | ||
1191 | goto err_out_iounmap; | 1173 | goto err_out_iounmap; |
1192 | } | 1174 | } |
1193 | 1175 | ||
@@ -1239,13 +1221,12 @@ static int __init macb_probe(struct platform_device *pdev) | |||
1239 | 1221 | ||
1240 | platform_set_drvdata(pdev, dev); | 1222 | platform_set_drvdata(pdev, dev); |
1241 | 1223 | ||
1242 | printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d (%pM)\n", | 1224 | netdev_info(dev, "Atmel MACB at 0x%08lx irq %d (%pM)\n", |
1243 | dev->name, dev->base_addr, dev->irq, dev->dev_addr); | 1225 | dev->base_addr, dev->irq, dev->dev_addr); |
1244 | 1226 | ||
1245 | phydev = bp->phy_dev; | 1227 | phydev = bp->phy_dev; |
1246 | printk(KERN_INFO "%s: attached PHY driver [%s] " | 1228 | netdev_info(dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", |
1247 | "(mii_bus:phy_addr=%s, irq=%d)\n", dev->name, | 1229 | phydev->drv->name, dev_name(&phydev->dev), phydev->irq); |
1248 | phydev->drv->name, dev_name(&phydev->dev), phydev->irq); | ||
1249 | 1230 | ||
1250 | return 0; | 1231 | return 0; |
1251 | 1232 | ||
@@ -1256,14 +1237,10 @@ err_out_free_irq: | |||
1256 | err_out_iounmap: | 1237 | err_out_iounmap: |
1257 | iounmap(bp->regs); | 1238 | iounmap(bp->regs); |
1258 | err_out_disable_clocks: | 1239 | err_out_disable_clocks: |
1259 | #ifndef CONFIG_ARCH_AT91 | ||
1260 | clk_disable(bp->hclk); | 1240 | clk_disable(bp->hclk); |
1261 | clk_put(bp->hclk); | 1241 | clk_put(bp->hclk); |
1262 | #endif | ||
1263 | clk_disable(bp->pclk); | 1242 | clk_disable(bp->pclk); |
1264 | #ifndef CONFIG_ARCH_AT91 | ||
1265 | err_out_put_pclk: | 1243 | err_out_put_pclk: |
1266 | #endif | ||
1267 | clk_put(bp->pclk); | 1244 | clk_put(bp->pclk); |
1268 | err_out_free_dev: | 1245 | err_out_free_dev: |
1269 | free_netdev(dev); | 1246 | free_netdev(dev); |
@@ -1289,10 +1266,8 @@ static int __exit macb_remove(struct platform_device *pdev) | |||
1289 | unregister_netdev(dev); | 1266 | unregister_netdev(dev); |
1290 | free_irq(dev->irq, dev); | 1267 | free_irq(dev->irq, dev); |
1291 | iounmap(bp->regs); | 1268 | iounmap(bp->regs); |
1292 | #ifndef CONFIG_ARCH_AT91 | ||
1293 | clk_disable(bp->hclk); | 1269 | clk_disable(bp->hclk); |
1294 | clk_put(bp->hclk); | 1270 | clk_put(bp->hclk); |
1295 | #endif | ||
1296 | clk_disable(bp->pclk); | 1271 | clk_disable(bp->pclk); |
1297 | clk_put(bp->pclk); | 1272 | clk_put(bp->pclk); |
1298 | free_netdev(dev); | 1273 | free_netdev(dev); |
@@ -1310,9 +1285,7 @@ static int macb_suspend(struct platform_device *pdev, pm_message_t state) | |||
1310 | 1285 | ||
1311 | netif_device_detach(netdev); | 1286 | netif_device_detach(netdev); |
1312 | 1287 | ||
1313 | #ifndef CONFIG_ARCH_AT91 | ||
1314 | clk_disable(bp->hclk); | 1288 | clk_disable(bp->hclk); |
1315 | #endif | ||
1316 | clk_disable(bp->pclk); | 1289 | clk_disable(bp->pclk); |
1317 | 1290 | ||
1318 | return 0; | 1291 | return 0; |
@@ -1324,9 +1297,7 @@ static int macb_resume(struct platform_device *pdev) | |||
1324 | struct macb *bp = netdev_priv(netdev); | 1297 | struct macb *bp = netdev_priv(netdev); |
1325 | 1298 | ||
1326 | clk_enable(bp->pclk); | 1299 | clk_enable(bp->pclk); |
1327 | #ifndef CONFIG_ARCH_AT91 | ||
1328 | clk_enable(bp->hclk); | 1300 | clk_enable(bp->hclk); |
1329 | #endif | ||
1330 | 1301 | ||
1331 | netif_device_attach(netdev); | 1302 | netif_device_attach(netdev); |
1332 | 1303 | ||
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index e39b77a4609a..dc474bc6522d 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -32,11 +32,17 @@ | |||
32 | 32 | ||
33 | #include <mach/at91_rtc.h> | 33 | #include <mach/at91_rtc.h> |
34 | 34 | ||
35 | #define at91_rtc_read(field) \ | ||
36 | __raw_readl(at91_rtc_regs + field) | ||
37 | #define at91_rtc_write(field, val) \ | ||
38 | __raw_writel((val), at91_rtc_regs + field) | ||
35 | 39 | ||
36 | #define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */ | 40 | #define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */ |
37 | 41 | ||
38 | static DECLARE_COMPLETION(at91_rtc_updated); | 42 | static DECLARE_COMPLETION(at91_rtc_updated); |
39 | static unsigned int at91_alarm_year = AT91_RTC_EPOCH; | 43 | static unsigned int at91_alarm_year = AT91_RTC_EPOCH; |
44 | static void __iomem *at91_rtc_regs; | ||
45 | static int irq; | ||
40 | 46 | ||
41 | /* | 47 | /* |
42 | * Decode time/date into rtc_time structure | 48 | * Decode time/date into rtc_time structure |
@@ -48,10 +54,10 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg, | |||
48 | 54 | ||
49 | /* must read twice in case it changes */ | 55 | /* must read twice in case it changes */ |
50 | do { | 56 | do { |
51 | time = at91_sys_read(timereg); | 57 | time = at91_rtc_read(timereg); |
52 | date = at91_sys_read(calreg); | 58 | date = at91_rtc_read(calreg); |
53 | } while ((time != at91_sys_read(timereg)) || | 59 | } while ((time != at91_rtc_read(timereg)) || |
54 | (date != at91_sys_read(calreg))); | 60 | (date != at91_rtc_read(calreg))); |
55 | 61 | ||
56 | tm->tm_sec = bcd2bin((time & AT91_RTC_SEC) >> 0); | 62 | tm->tm_sec = bcd2bin((time & AT91_RTC_SEC) >> 0); |
57 | tm->tm_min = bcd2bin((time & AT91_RTC_MIN) >> 8); | 63 | tm->tm_min = bcd2bin((time & AT91_RTC_MIN) >> 8); |
@@ -98,19 +104,19 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
98 | tm->tm_hour, tm->tm_min, tm->tm_sec); | 104 | tm->tm_hour, tm->tm_min, tm->tm_sec); |
99 | 105 | ||
100 | /* Stop Time/Calendar from counting */ | 106 | /* Stop Time/Calendar from counting */ |
101 | cr = at91_sys_read(AT91_RTC_CR); | 107 | cr = at91_rtc_read(AT91_RTC_CR); |
102 | at91_sys_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM); | 108 | at91_rtc_write(AT91_RTC_CR, cr | AT91_RTC_UPDCAL | AT91_RTC_UPDTIM); |
103 | 109 | ||
104 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ACKUPD); | 110 | at91_rtc_write(AT91_RTC_IER, AT91_RTC_ACKUPD); |
105 | wait_for_completion(&at91_rtc_updated); /* wait for ACKUPD interrupt */ | 111 | wait_for_completion(&at91_rtc_updated); /* wait for ACKUPD interrupt */ |
106 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD); | 112 | at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ACKUPD); |
107 | 113 | ||
108 | at91_sys_write(AT91_RTC_TIMR, | 114 | at91_rtc_write(AT91_RTC_TIMR, |
109 | bin2bcd(tm->tm_sec) << 0 | 115 | bin2bcd(tm->tm_sec) << 0 |
110 | | bin2bcd(tm->tm_min) << 8 | 116 | | bin2bcd(tm->tm_min) << 8 |
111 | | bin2bcd(tm->tm_hour) << 16); | 117 | | bin2bcd(tm->tm_hour) << 16); |
112 | 118 | ||
113 | at91_sys_write(AT91_RTC_CALR, | 119 | at91_rtc_write(AT91_RTC_CALR, |
114 | bin2bcd((tm->tm_year + 1900) / 100) /* century */ | 120 | bin2bcd((tm->tm_year + 1900) / 100) /* century */ |
115 | | bin2bcd(tm->tm_year % 100) << 8 /* year */ | 121 | | bin2bcd(tm->tm_year % 100) << 8 /* year */ |
116 | | bin2bcd(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */ | 122 | | bin2bcd(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */ |
@@ -118,8 +124,8 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm) | |||
118 | | bin2bcd(tm->tm_mday) << 24); | 124 | | bin2bcd(tm->tm_mday) << 24); |
119 | 125 | ||
120 | /* Restart Time/Calendar */ | 126 | /* Restart Time/Calendar */ |
121 | cr = at91_sys_read(AT91_RTC_CR); | 127 | cr = at91_rtc_read(AT91_RTC_CR); |
122 | at91_sys_write(AT91_RTC_CR, cr & ~(AT91_RTC_UPDCAL | AT91_RTC_UPDTIM)); | 128 | at91_rtc_write(AT91_RTC_CR, cr & ~(AT91_RTC_UPDCAL | AT91_RTC_UPDTIM)); |
123 | 129 | ||
124 | return 0; | 130 | return 0; |
125 | } | 131 | } |
@@ -135,7 +141,7 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
135 | tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); | 141 | tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year); |
136 | tm->tm_year = at91_alarm_year - 1900; | 142 | tm->tm_year = at91_alarm_year - 1900; |
137 | 143 | ||
138 | alrm->enabled = (at91_sys_read(AT91_RTC_IMR) & AT91_RTC_ALARM) | 144 | alrm->enabled = (at91_rtc_read(AT91_RTC_IMR) & AT91_RTC_ALARM) |
139 | ? 1 : 0; | 145 | ? 1 : 0; |
140 | 146 | ||
141 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, | 147 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, |
@@ -160,20 +166,20 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
160 | tm.tm_min = alrm->time.tm_min; | 166 | tm.tm_min = alrm->time.tm_min; |
161 | tm.tm_sec = alrm->time.tm_sec; | 167 | tm.tm_sec = alrm->time.tm_sec; |
162 | 168 | ||
163 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); | 169 | at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ALARM); |
164 | at91_sys_write(AT91_RTC_TIMALR, | 170 | at91_rtc_write(AT91_RTC_TIMALR, |
165 | bin2bcd(tm.tm_sec) << 0 | 171 | bin2bcd(tm.tm_sec) << 0 |
166 | | bin2bcd(tm.tm_min) << 8 | 172 | | bin2bcd(tm.tm_min) << 8 |
167 | | bin2bcd(tm.tm_hour) << 16 | 173 | | bin2bcd(tm.tm_hour) << 16 |
168 | | AT91_RTC_HOUREN | AT91_RTC_MINEN | AT91_RTC_SECEN); | 174 | | AT91_RTC_HOUREN | AT91_RTC_MINEN | AT91_RTC_SECEN); |
169 | at91_sys_write(AT91_RTC_CALALR, | 175 | at91_rtc_write(AT91_RTC_CALALR, |
170 | bin2bcd(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */ | 176 | bin2bcd(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */ |
171 | | bin2bcd(tm.tm_mday) << 24 | 177 | | bin2bcd(tm.tm_mday) << 24 |
172 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); | 178 | | AT91_RTC_DATEEN | AT91_RTC_MTHEN); |
173 | 179 | ||
174 | if (alrm->enabled) { | 180 | if (alrm->enabled) { |
175 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM); | 181 | at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM); |
176 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); | 182 | at91_rtc_write(AT91_RTC_IER, AT91_RTC_ALARM); |
177 | } | 183 | } |
178 | 184 | ||
179 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, | 185 | pr_debug("%s(): %4d-%02d-%02d %02d:%02d:%02d\n", __func__, |
@@ -188,10 +194,10 @@ static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
188 | pr_debug("%s(): cmd=%08x\n", __func__, enabled); | 194 | pr_debug("%s(): cmd=%08x\n", __func__, enabled); |
189 | 195 | ||
190 | if (enabled) { | 196 | if (enabled) { |
191 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_ALARM); | 197 | at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM); |
192 | at91_sys_write(AT91_RTC_IER, AT91_RTC_ALARM); | 198 | at91_rtc_write(AT91_RTC_IER, AT91_RTC_ALARM); |
193 | } else | 199 | } else |
194 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ALARM); | 200 | at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ALARM); |
195 | 201 | ||
196 | return 0; | 202 | return 0; |
197 | } | 203 | } |
@@ -200,7 +206,7 @@ static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
200 | */ | 206 | */ |
201 | static int at91_rtc_proc(struct device *dev, struct seq_file *seq) | 207 | static int at91_rtc_proc(struct device *dev, struct seq_file *seq) |
202 | { | 208 | { |
203 | unsigned long imr = at91_sys_read(AT91_RTC_IMR); | 209 | unsigned long imr = at91_rtc_read(AT91_RTC_IMR); |
204 | 210 | ||
205 | seq_printf(seq, "update_IRQ\t: %s\n", | 211 | seq_printf(seq, "update_IRQ\t: %s\n", |
206 | (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); | 212 | (imr & AT91_RTC_ACKUPD) ? "yes" : "no"); |
@@ -220,7 +226,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) | |||
220 | unsigned int rtsr; | 226 | unsigned int rtsr; |
221 | unsigned long events = 0; | 227 | unsigned long events = 0; |
222 | 228 | ||
223 | rtsr = at91_sys_read(AT91_RTC_SR) & at91_sys_read(AT91_RTC_IMR); | 229 | rtsr = at91_rtc_read(AT91_RTC_SR) & at91_rtc_read(AT91_RTC_IMR); |
224 | if (rtsr) { /* this interrupt is shared! Is it ours? */ | 230 | if (rtsr) { /* this interrupt is shared! Is it ours? */ |
225 | if (rtsr & AT91_RTC_ALARM) | 231 | if (rtsr & AT91_RTC_ALARM) |
226 | events |= (RTC_AF | RTC_IRQF); | 232 | events |= (RTC_AF | RTC_IRQF); |
@@ -229,7 +235,7 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) | |||
229 | if (rtsr & AT91_RTC_ACKUPD) | 235 | if (rtsr & AT91_RTC_ACKUPD) |
230 | complete(&at91_rtc_updated); | 236 | complete(&at91_rtc_updated); |
231 | 237 | ||
232 | at91_sys_write(AT91_RTC_SCCR, rtsr); /* clear status reg */ | 238 | at91_rtc_write(AT91_RTC_SCCR, rtsr); /* clear status reg */ |
233 | 239 | ||
234 | rtc_update_irq(rtc, 1, events); | 240 | rtc_update_irq(rtc, 1, events); |
235 | 241 | ||
@@ -256,22 +262,41 @@ static const struct rtc_class_ops at91_rtc_ops = { | |||
256 | static int __init at91_rtc_probe(struct platform_device *pdev) | 262 | static int __init at91_rtc_probe(struct platform_device *pdev) |
257 | { | 263 | { |
258 | struct rtc_device *rtc; | 264 | struct rtc_device *rtc; |
259 | int ret; | 265 | struct resource *regs; |
266 | int ret = 0; | ||
260 | 267 | ||
261 | at91_sys_write(AT91_RTC_CR, 0); | 268 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
262 | at91_sys_write(AT91_RTC_MR, 0); /* 24 hour mode */ | 269 | if (!regs) { |
270 | dev_err(&pdev->dev, "no mmio resource defined\n"); | ||
271 | return -ENXIO; | ||
272 | } | ||
273 | |||
274 | irq = platform_get_irq(pdev, 0); | ||
275 | if (irq < 0) { | ||
276 | dev_err(&pdev->dev, "no irq resource defined\n"); | ||
277 | return -ENXIO; | ||
278 | } | ||
279 | |||
280 | at91_rtc_regs = ioremap(regs->start, resource_size(regs)); | ||
281 | if (!at91_rtc_regs) { | ||
282 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); | ||
283 | return -ENOMEM; | ||
284 | } | ||
285 | |||
286 | at91_rtc_write(AT91_RTC_CR, 0); | ||
287 | at91_rtc_write(AT91_RTC_MR, 0); /* 24 hour mode */ | ||
263 | 288 | ||
264 | /* Disable all interrupts */ | 289 | /* Disable all interrupts */ |
265 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | | 290 | at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | |
266 | AT91_RTC_SECEV | AT91_RTC_TIMEV | | 291 | AT91_RTC_SECEV | AT91_RTC_TIMEV | |
267 | AT91_RTC_CALEV); | 292 | AT91_RTC_CALEV); |
268 | 293 | ||
269 | ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, | 294 | ret = request_irq(irq, at91_rtc_interrupt, |
270 | IRQF_SHARED, | 295 | IRQF_SHARED, |
271 | "at91_rtc", pdev); | 296 | "at91_rtc", pdev); |
272 | if (ret) { | 297 | if (ret) { |
273 | printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", | 298 | printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", |
274 | AT91_ID_SYS); | 299 | irq); |
275 | return ret; | 300 | return ret; |
276 | } | 301 | } |
277 | 302 | ||
@@ -284,7 +309,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
284 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 309 | rtc = rtc_device_register(pdev->name, &pdev->dev, |
285 | &at91_rtc_ops, THIS_MODULE); | 310 | &at91_rtc_ops, THIS_MODULE); |
286 | if (IS_ERR(rtc)) { | 311 | if (IS_ERR(rtc)) { |
287 | free_irq(AT91_ID_SYS, pdev); | 312 | free_irq(irq, pdev); |
288 | return PTR_ERR(rtc); | 313 | return PTR_ERR(rtc); |
289 | } | 314 | } |
290 | platform_set_drvdata(pdev, rtc); | 315 | platform_set_drvdata(pdev, rtc); |
@@ -301,10 +326,10 @@ static int __exit at91_rtc_remove(struct platform_device *pdev) | |||
301 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 326 | struct rtc_device *rtc = platform_get_drvdata(pdev); |
302 | 327 | ||
303 | /* Disable all interrupts */ | 328 | /* Disable all interrupts */ |
304 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | | 329 | at91_rtc_write(AT91_RTC_IDR, AT91_RTC_ACKUPD | AT91_RTC_ALARM | |
305 | AT91_RTC_SECEV | AT91_RTC_TIMEV | | 330 | AT91_RTC_SECEV | AT91_RTC_TIMEV | |
306 | AT91_RTC_CALEV); | 331 | AT91_RTC_CALEV); |
307 | free_irq(AT91_ID_SYS, pdev); | 332 | free_irq(irq, pdev); |
308 | 333 | ||
309 | rtc_device_unregister(rtc); | 334 | rtc_device_unregister(rtc); |
310 | platform_set_drvdata(pdev, NULL); | 335 | platform_set_drvdata(pdev, NULL); |
@@ -323,13 +348,13 @@ static int at91_rtc_suspend(struct device *dev) | |||
323 | /* this IRQ is shared with DBGU and other hardware which isn't | 348 | /* this IRQ is shared with DBGU and other hardware which isn't |
324 | * necessarily doing PM like we are... | 349 | * necessarily doing PM like we are... |
325 | */ | 350 | */ |
326 | at91_rtc_imr = at91_sys_read(AT91_RTC_IMR) | 351 | at91_rtc_imr = at91_rtc_read(AT91_RTC_IMR) |
327 | & (AT91_RTC_ALARM|AT91_RTC_SECEV); | 352 | & (AT91_RTC_ALARM|AT91_RTC_SECEV); |
328 | if (at91_rtc_imr) { | 353 | if (at91_rtc_imr) { |
329 | if (device_may_wakeup(dev)) | 354 | if (device_may_wakeup(dev)) |
330 | enable_irq_wake(AT91_ID_SYS); | 355 | enable_irq_wake(irq); |
331 | else | 356 | else |
332 | at91_sys_write(AT91_RTC_IDR, at91_rtc_imr); | 357 | at91_rtc_write(AT91_RTC_IDR, at91_rtc_imr); |
333 | } | 358 | } |
334 | return 0; | 359 | return 0; |
335 | } | 360 | } |
@@ -338,9 +363,9 @@ static int at91_rtc_resume(struct device *dev) | |||
338 | { | 363 | { |
339 | if (at91_rtc_imr) { | 364 | if (at91_rtc_imr) { |
340 | if (device_may_wakeup(dev)) | 365 | if (device_may_wakeup(dev)) |
341 | disable_irq_wake(AT91_ID_SYS); | 366 | disable_irq_wake(irq); |
342 | else | 367 | else |
343 | at91_sys_write(AT91_RTC_IER, at91_rtc_imr); | 368 | at91_rtc_write(AT91_RTC_IER, at91_rtc_imr); |
344 | } | 369 | } |
345 | return 0; | 370 | return 0; |
346 | } | 371 | } |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 8efe0fa9228d..1ed56d8492d7 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -1748,7 +1748,7 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1748 | 1748 | ||
1749 | /* rm9200 needs manual D+ pullup; off by default */ | 1749 | /* rm9200 needs manual D+ pullup; off by default */ |
1750 | if (cpu_is_at91rm9200()) { | 1750 | if (cpu_is_at91rm9200()) { |
1751 | if (udc->board.pullup_pin <= 0) { | 1751 | if (gpio_is_valid(udc->board.pullup_pin)) { |
1752 | DBG("no D+ pullup?\n"); | 1752 | DBG("no D+ pullup?\n"); |
1753 | retval = -ENODEV; | 1753 | retval = -ENODEV; |
1754 | goto fail0; | 1754 | goto fail0; |
@@ -1815,7 +1815,7 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1815 | DBG("request irq %d failed\n", udc->udp_irq); | 1815 | DBG("request irq %d failed\n", udc->udp_irq); |
1816 | goto fail1; | 1816 | goto fail1; |
1817 | } | 1817 | } |
1818 | if (udc->board.vbus_pin > 0) { | 1818 | if (gpio_is_valid(udc->board.vbus_pin)) { |
1819 | retval = gpio_request(udc->board.vbus_pin, "udc_vbus"); | 1819 | retval = gpio_request(udc->board.vbus_pin, "udc_vbus"); |
1820 | if (retval < 0) { | 1820 | if (retval < 0) { |
1821 | DBG("request vbus pin failed\n"); | 1821 | DBG("request vbus pin failed\n"); |
@@ -1859,10 +1859,10 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1859 | INFO("%s version %s\n", driver_name, DRIVER_VERSION); | 1859 | INFO("%s version %s\n", driver_name, DRIVER_VERSION); |
1860 | return 0; | 1860 | return 0; |
1861 | fail4: | 1861 | fail4: |
1862 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled) | 1862 | if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled) |
1863 | free_irq(udc->board.vbus_pin, udc); | 1863 | free_irq(udc->board.vbus_pin, udc); |
1864 | fail3: | 1864 | fail3: |
1865 | if (udc->board.vbus_pin > 0) | 1865 | if (gpio_is_valid(udc->board.vbus_pin)) |
1866 | gpio_free(udc->board.vbus_pin); | 1866 | gpio_free(udc->board.vbus_pin); |
1867 | fail2: | 1867 | fail2: |
1868 | free_irq(udc->udp_irq, udc); | 1868 | free_irq(udc->udp_irq, udc); |
@@ -1897,7 +1897,7 @@ static int __exit at91udc_remove(struct platform_device *pdev) | |||
1897 | 1897 | ||
1898 | device_init_wakeup(&pdev->dev, 0); | 1898 | device_init_wakeup(&pdev->dev, 0); |
1899 | remove_debug_file(udc); | 1899 | remove_debug_file(udc); |
1900 | if (udc->board.vbus_pin > 0) { | 1900 | if (gpio_is_valid(udc->board.vbus_pin)) { |
1901 | free_irq(udc->board.vbus_pin, udc); | 1901 | free_irq(udc->board.vbus_pin, udc); |
1902 | gpio_free(udc->board.vbus_pin); | 1902 | gpio_free(udc->board.vbus_pin); |
1903 | } | 1903 | } |
@@ -1941,7 +1941,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1941 | enable_irq_wake(udc->udp_irq); | 1941 | enable_irq_wake(udc->udp_irq); |
1942 | 1942 | ||
1943 | udc->active_suspend = wake; | 1943 | udc->active_suspend = wake; |
1944 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled && wake) | 1944 | if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled && wake) |
1945 | enable_irq_wake(udc->board.vbus_pin); | 1945 | enable_irq_wake(udc->board.vbus_pin); |
1946 | return 0; | 1946 | return 0; |
1947 | } | 1947 | } |
@@ -1951,7 +1951,7 @@ static int at91udc_resume(struct platform_device *pdev) | |||
1951 | struct at91_udc *udc = platform_get_drvdata(pdev); | 1951 | struct at91_udc *udc = platform_get_drvdata(pdev); |
1952 | unsigned long flags; | 1952 | unsigned long flags; |
1953 | 1953 | ||
1954 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled && | 1954 | if (gpio_is_valid(udc->board.vbus_pin) && !udc->board.vbus_polled && |
1955 | udc->active_suspend) | 1955 | udc->active_suspend) |
1956 | disable_irq_wake(udc->board.vbus_pin); | 1956 | disable_irq_wake(udc->board.vbus_pin); |
1957 | 1957 | ||
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 95a9fec38e89..5df0b0e3392b 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -223,7 +223,7 @@ static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int | |||
223 | if (port < 0 || port >= 2) | 223 | if (port < 0 || port >= 2) |
224 | return; | 224 | return; |
225 | 225 | ||
226 | if (pdata->vbus_pin[port] <= 0) | 226 | if (!gpio_is_valid(pdata->vbus_pin[port])) |
227 | return; | 227 | return; |
228 | 228 | ||
229 | gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); | 229 | gpio_set_value(pdata->vbus_pin[port], !pdata->vbus_pin_inverted ^ enable); |
@@ -234,7 +234,7 @@ static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | |||
234 | if (port < 0 || port >= 2) | 234 | if (port < 0 || port >= 2) |
235 | return -EINVAL; | 235 | return -EINVAL; |
236 | 236 | ||
237 | if (pdata->vbus_pin[port] <= 0) | 237 | if (!gpio_is_valid(pdata->vbus_pin[port])) |
238 | return -EINVAL; | 238 | return -EINVAL; |
239 | 239 | ||
240 | return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; | 240 | return gpio_get_value(pdata->vbus_pin[port]) ^ !pdata->vbus_pin_inverted; |
@@ -465,7 +465,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
465 | 465 | ||
466 | if (pdata) { | 466 | if (pdata) { |
467 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { | 467 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { |
468 | if (pdata->vbus_pin[i] <= 0) | 468 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
469 | continue; | 469 | continue; |
470 | gpio_request(pdata->vbus_pin[i], "ohci_vbus"); | 470 | gpio_request(pdata->vbus_pin[i], "ohci_vbus"); |
471 | ohci_at91_usb_set_power(pdata, i, 1); | 471 | ohci_at91_usb_set_power(pdata, i, 1); |
@@ -474,7 +474,7 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
474 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | 474 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { |
475 | int ret; | 475 | int ret; |
476 | 476 | ||
477 | if (pdata->overcurrent_pin[i] <= 0) | 477 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
478 | continue; | 478 | continue; |
479 | gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); | 479 | gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); |
480 | 480 | ||
@@ -499,14 +499,14 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) | |||
499 | 499 | ||
500 | if (pdata) { | 500 | if (pdata) { |
501 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { | 501 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { |
502 | if (pdata->vbus_pin[i] <= 0) | 502 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
503 | continue; | 503 | continue; |
504 | ohci_at91_usb_set_power(pdata, i, 0); | 504 | ohci_at91_usb_set_power(pdata, i, 0); |
505 | gpio_free(pdata->vbus_pin[i]); | 505 | gpio_free(pdata->vbus_pin[i]); |
506 | } | 506 | } |
507 | 507 | ||
508 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | 508 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { |
509 | if (pdata->overcurrent_pin[i] <= 0) | 509 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
510 | continue; | 510 | continue; |
511 | free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); | 511 | free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); |
512 | gpio_free(pdata->overcurrent_pin[i]); | 512 | gpio_free(pdata->overcurrent_pin[i]); |
diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index 87445b2d72a7..00562566ef5f 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c | |||
@@ -35,6 +35,11 @@ | |||
35 | 35 | ||
36 | #define DRV_NAME "AT91SAM9 Watchdog" | 36 | #define DRV_NAME "AT91SAM9 Watchdog" |
37 | 37 | ||
38 | #define wdt_read(field) \ | ||
39 | __raw_readl(at91wdt_private.base + field) | ||
40 | #define wdt_write(field, val) \ | ||
41 | __raw_writel((val), at91wdt_private.base + field) | ||
42 | |||
38 | /* AT91SAM9 watchdog runs a 12bit counter @ 256Hz, | 43 | /* AT91SAM9 watchdog runs a 12bit counter @ 256Hz, |
39 | * use this to convert a watchdog | 44 | * use this to convert a watchdog |
40 | * value from/to milliseconds. | 45 | * value from/to milliseconds. |
@@ -63,6 +68,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " | |||
63 | static void at91_ping(unsigned long data); | 68 | static void at91_ping(unsigned long data); |
64 | 69 | ||
65 | static struct { | 70 | static struct { |
71 | void __iomem *base; | ||
66 | unsigned long next_heartbeat; /* the next_heartbeat for the timer */ | 72 | unsigned long next_heartbeat; /* the next_heartbeat for the timer */ |
67 | unsigned long open; | 73 | unsigned long open; |
68 | char expect_close; | 74 | char expect_close; |
@@ -77,7 +83,7 @@ static struct { | |||
77 | */ | 83 | */ |
78 | static inline void at91_wdt_reset(void) | 84 | static inline void at91_wdt_reset(void) |
79 | { | 85 | { |
80 | at91_sys_write(AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT); | 86 | wdt_write(AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT); |
81 | } | 87 | } |
82 | 88 | ||
83 | /* | 89 | /* |
@@ -132,7 +138,7 @@ static int at91_wdt_settimeout(unsigned int timeout) | |||
132 | unsigned int mr; | 138 | unsigned int mr; |
133 | 139 | ||
134 | /* Check if disabled */ | 140 | /* Check if disabled */ |
135 | mr = at91_sys_read(AT91_WDT_MR); | 141 | mr = wdt_read(AT91_WDT_MR); |
136 | if (mr & AT91_WDT_WDDIS) { | 142 | if (mr & AT91_WDT_WDDIS) { |
137 | printk(KERN_ERR DRV_NAME": sorry, watchdog is disabled\n"); | 143 | printk(KERN_ERR DRV_NAME": sorry, watchdog is disabled\n"); |
138 | return -EIO; | 144 | return -EIO; |
@@ -149,7 +155,7 @@ static int at91_wdt_settimeout(unsigned int timeout) | |||
149 | | AT91_WDT_WDDBGHLT /* disabled in debug mode */ | 155 | | AT91_WDT_WDDBGHLT /* disabled in debug mode */ |
150 | | AT91_WDT_WDD /* restart at any time */ | 156 | | AT91_WDT_WDD /* restart at any time */ |
151 | | (timeout & AT91_WDT_WDV); /* timer value */ | 157 | | (timeout & AT91_WDT_WDV); /* timer value */ |
152 | at91_sys_write(AT91_WDT_MR, reg); | 158 | wdt_write(AT91_WDT_MR, reg); |
153 | 159 | ||
154 | return 0; | 160 | return 0; |
155 | } | 161 | } |
@@ -248,12 +254,22 @@ static struct miscdevice at91wdt_miscdev = { | |||
248 | 254 | ||
249 | static int __init at91wdt_probe(struct platform_device *pdev) | 255 | static int __init at91wdt_probe(struct platform_device *pdev) |
250 | { | 256 | { |
257 | struct resource *r; | ||
251 | int res; | 258 | int res; |
252 | 259 | ||
253 | if (at91wdt_miscdev.parent) | 260 | if (at91wdt_miscdev.parent) |
254 | return -EBUSY; | 261 | return -EBUSY; |
255 | at91wdt_miscdev.parent = &pdev->dev; | 262 | at91wdt_miscdev.parent = &pdev->dev; |
256 | 263 | ||
264 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
265 | if (!r) | ||
266 | return -ENODEV; | ||
267 | at91wdt_private.base = ioremap(r->start, resource_size(r)); | ||
268 | if (!at91wdt_private.base) { | ||
269 | dev_err(&pdev->dev, "failed to map registers, aborting.\n"); | ||
270 | return -ENOMEM; | ||
271 | } | ||
272 | |||
257 | /* Set watchdog */ | 273 | /* Set watchdog */ |
258 | res = at91_wdt_settimeout(ms_to_ticks(WDT_HW_TIMEOUT * 1000)); | 274 | res = at91_wdt_settimeout(ms_to_ticks(WDT_HW_TIMEOUT * 1000)); |
259 | if (res) | 275 | if (res) |
diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h index 757f9cab5c82..c6fbb2e6c41b 100644 --- a/drivers/watchdog/at91sam9_wdt.h +++ b/drivers/watchdog/at91sam9_wdt.h | |||
@@ -16,11 +16,11 @@ | |||
16 | #ifndef AT91_WDT_H | 16 | #ifndef AT91_WDT_H |
17 | #define AT91_WDT_H | 17 | #define AT91_WDT_H |
18 | 18 | ||
19 | #define AT91_WDT_CR (AT91_WDT + 0x00) /* Watchdog Control Register */ | 19 | #define AT91_WDT_CR 0x00 /* Watchdog Control Register */ |
20 | #define AT91_WDT_WDRSTT (1 << 0) /* Restart */ | 20 | #define AT91_WDT_WDRSTT (1 << 0) /* Restart */ |
21 | #define AT91_WDT_KEY (0xa5 << 24) /* KEY Password */ | 21 | #define AT91_WDT_KEY (0xa5 << 24) /* KEY Password */ |
22 | 22 | ||
23 | #define AT91_WDT_MR (AT91_WDT + 0x04) /* Watchdog Mode Register */ | 23 | #define AT91_WDT_MR 0x04 /* Watchdog Mode Register */ |
24 | #define AT91_WDT_WDV (0xfff << 0) /* Counter Value */ | 24 | #define AT91_WDT_WDV (0xfff << 0) /* Counter Value */ |
25 | #define AT91_WDT_WDFIEN (1 << 12) /* Fault Interrupt Enable */ | 25 | #define AT91_WDT_WDFIEN (1 << 12) /* Fault Interrupt Enable */ |
26 | #define AT91_WDT_WDRSTEN (1 << 13) /* Reset Processor */ | 26 | #define AT91_WDT_WDRSTEN (1 << 13) /* Reset Processor */ |
@@ -30,7 +30,7 @@ | |||
30 | #define AT91_WDT_WDDBGHLT (1 << 28) /* Debug Halt */ | 30 | #define AT91_WDT_WDDBGHLT (1 << 28) /* Debug Halt */ |
31 | #define AT91_WDT_WDIDLEHLT (1 << 29) /* Idle Halt */ | 31 | #define AT91_WDT_WDIDLEHLT (1 << 29) /* Idle Halt */ |
32 | 32 | ||
33 | #define AT91_WDT_SR (AT91_WDT + 0x08) /* Watchdog Status Register */ | 33 | #define AT91_WDT_SR 0x08 /* Watchdog Status Register */ |
34 | #define AT91_WDT_WDUNF (1 << 0) /* Watchdog Underflow */ | 34 | #define AT91_WDT_WDUNF (1 << 0) /* Watchdog Underflow */ |
35 | #define AT91_WDT_WDERR (1 << 1) /* Watchdog Error */ | 35 | #define AT91_WDT_WDERR (1 << 1) /* Watchdog Error */ |
36 | 36 | ||