diff options
| author | Arnd Bergmann <arnd@arndb.de> | 2019-02-15 11:40:26 -0500 |
|---|---|---|
| committer | Arnd Bergmann <arnd@arndb.de> | 2019-02-15 14:38:14 -0500 |
| commit | b8961b1eb7d2d6a28b9a51294b0b18aaa5f10d52 (patch) | |
| tree | a8343adbb3efbcb0918306f384e95d78a34dee75 | |
| parent | ad75174f39f4729ee08412bc1d653dfe21a50754 (diff) | |
| parent | 23fa70e40a42e8dfeac654b8cc0e5b463e54af25 (diff) | |
Merge tag 'davinci-for-v5.1/soc-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci into arm/fixes
DaVinci SoC updates for v5.1 (part 2)
This pull request contains changes needed to help get rid of
hard-coded GPIO base value passed from DaVinci platform data.
The OHCI related changes also help by moving over-current support
from board-files to OHCI driver making future DT-coversion easy.
The OHCI parts are acked by its maintainer.
* tag 'davinci-for-v5.1/soc-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci:
usb: ohci-da8xx: remove unused callbacks from platform data
ARM: davinci: da830-evm: remove legacy usb helpers
ARM: davinci: omapl138-hawk: remove legacy usb helpers
usb: ohci-da8xx: add vbus and overcurrent gpios
ARM: davinci: da830-evm: use gpio lookup entries for usb gpios
ARM: davinci: omapl138-hawk: use gpio lookup entries for usb gpios
usb: ohci-da8xx: add a helper pointer to &pdev->dev
usb: ohci-da8xx: add a new line after local variables
ARM: davinci: da850-evm: use GPIO hogs instead of the legacy API
ARM: davinci: mityomapl138: use device properties for at24 eeprom
ARM: davinci: mityomapl138: use nvmem notifiers
ARM: davinci: remove dead code related to MAC address reading
ARM: davinci: sffsdr: use device properties for at24 eeprom
ARM: davinci: sffsdr: fix the at24 eeprom device name
ARM: davinci: dm646x-evm: use device properties for at24 eeprom
ARM: davinci: dm644x-evm: use device properties for at24 eeprom
ARM: davinci: da830-evm: use device properties for at24 eeprom
ARM: davinci: dm365-evm: use device properties for at24 eeprom
ARM: davinci: mityomapl138: don't read the MAC address from machine code
ARM: davinci: da850-evm: remove dead MTD code
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
| -rw-r--r-- | arch/arm/mach-davinci/board-da830-evm.c | 86 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/board-da850-evm.c | 50 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/board-dm365-evm.c | 13 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/board-dm644x-evm.c | 13 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/board-dm646x-evm.c | 13 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/board-mityomapl138.c | 38 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/board-omapl138-hawk.c | 81 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/board-sffsdr.c | 13 | ||||
| -rw-r--r-- | arch/arm/mach-davinci/common.c | 15 | ||||
| -rw-r--r-- | drivers/usb/host/ohci-da8xx.c | 118 | ||||
| -rw-r--r-- | include/linux/davinci_emac.h | 1 | ||||
| -rw-r--r-- | include/linux/platform_data/usb-davinci.h | 14 |
12 files changed, 138 insertions, 317 deletions
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c index c4da635ee4ce..3a2124212a7f 100644 --- a/arch/arm/mach-davinci/board-da830-evm.c +++ b/arch/arm/mach-davinci/board-da830-evm.c | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
| 19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
| 20 | #include <linux/platform_data/pcf857x.h> | 20 | #include <linux/platform_data/pcf857x.h> |
| 21 | #include <linux/platform_data/at24.h> | 21 | #include <linux/property.h> |
| 22 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
| 23 | #include <linux/mtd/partitions.h> | 23 | #include <linux/mtd/partitions.h> |
| 24 | #include <linux/spi/spi.h> | 24 | #include <linux/spi/spi.h> |
| @@ -52,62 +52,19 @@ static const short da830_evm_usb11_pins[] = { | |||
| 52 | -1 | 52 | -1 |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | static da8xx_ocic_handler_t da830_evm_usb_ocic_handler; | 55 | static struct gpiod_lookup_table da830_evm_usb_gpio_lookup = { |
| 56 | 56 | .dev_id = "ohci-da8xx", | |
| 57 | static int da830_evm_usb_set_power(unsigned port, int on) | 57 | .table = { |
| 58 | { | 58 | GPIO_LOOKUP("davinci_gpio", ON_BD_USB_DRV, "vbus", 0), |
| 59 | gpio_set_value(ON_BD_USB_DRV, on); | 59 | GPIO_LOOKUP("davinci_gpio", ON_BD_USB_OVC, "oc", 0), |
| 60 | return 0; | 60 | }, |
| 61 | } | 61 | }; |
| 62 | |||
| 63 | static int da830_evm_usb_get_power(unsigned port) | ||
| 64 | { | ||
| 65 | return gpio_get_value(ON_BD_USB_DRV); | ||
| 66 | } | ||
| 67 | |||
| 68 | static int da830_evm_usb_get_oci(unsigned port) | ||
| 69 | { | ||
| 70 | return !gpio_get_value(ON_BD_USB_OVC); | ||
| 71 | } | ||
| 72 | |||
| 73 | static irqreturn_t da830_evm_usb_ocic_irq(int, void *); | ||
| 74 | |||
| 75 | static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler) | ||
| 76 | { | ||
| 77 | int irq = gpio_to_irq(ON_BD_USB_OVC); | ||
| 78 | int error = 0; | ||
| 79 | |||
| 80 | if (handler != NULL) { | ||
| 81 | da830_evm_usb_ocic_handler = handler; | ||
| 82 | |||
| 83 | error = request_irq(irq, da830_evm_usb_ocic_irq, | ||
| 84 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
| 85 | "OHCI over-current indicator", NULL); | ||
| 86 | if (error) | ||
| 87 | pr_err("%s: could not request IRQ to watch over-current indicator changes\n", | ||
| 88 | __func__); | ||
| 89 | } else | ||
| 90 | free_irq(irq, NULL); | ||
| 91 | |||
| 92 | return error; | ||
| 93 | } | ||
| 94 | 62 | ||
| 95 | static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = { | 63 | static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = { |
| 96 | .set_power = da830_evm_usb_set_power, | ||
| 97 | .get_power = da830_evm_usb_get_power, | ||
| 98 | .get_oci = da830_evm_usb_get_oci, | ||
| 99 | .ocic_notify = da830_evm_usb_ocic_notify, | ||
| 100 | |||
| 101 | /* TPS2065 switch @ 5V */ | 64 | /* TPS2065 switch @ 5V */ |
| 102 | .potpgt = (3 + 1) / 2, /* 3 ms max */ | 65 | .potpgt = (3 + 1) / 2, /* 3 ms max */ |
| 103 | }; | 66 | }; |
| 104 | 67 | ||
| 105 | static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id) | ||
| 106 | { | ||
| 107 | da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata, 1); | ||
| 108 | return IRQ_HANDLED; | ||
| 109 | } | ||
| 110 | |||
| 111 | static __init void da830_evm_usb_init(void) | 68 | static __init void da830_evm_usb_init(void) |
| 112 | { | 69 | { |
| 113 | int ret; | 70 | int ret; |
| @@ -142,21 +99,7 @@ static __init void da830_evm_usb_init(void) | |||
| 142 | return; | 99 | return; |
| 143 | } | 100 | } |
| 144 | 101 | ||
| 145 | ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV"); | 102 | gpiod_add_lookup_table(&da830_evm_usb_gpio_lookup); |
| 146 | if (ret) { | ||
| 147 | pr_err("%s: failed to request GPIO for USB 1.1 port power control: %d\n", | ||
| 148 | __func__, ret); | ||
| 149 | return; | ||
| 150 | } | ||
| 151 | gpio_direction_output(ON_BD_USB_DRV, 0); | ||
| 152 | |||
| 153 | ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC"); | ||
| 154 | if (ret) { | ||
| 155 | pr_err("%s: failed to request GPIO for USB 1.1 port over-current indicator: %d\n", | ||
| 156 | __func__, ret); | ||
| 157 | return; | ||
| 158 | } | ||
| 159 | gpio_direction_input(ON_BD_USB_OVC); | ||
| 160 | 103 | ||
| 161 | ret = da8xx_register_usb11(&da830_evm_usb11_pdata); | 104 | ret = da8xx_register_usb11(&da830_evm_usb11_pdata); |
| 162 | if (ret) | 105 | if (ret) |
| @@ -457,12 +400,9 @@ static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = { | |||
| 457 | .con_id = "mac-address", | 400 | .con_id = "mac-address", |
| 458 | }; | 401 | }; |
| 459 | 402 | ||
| 460 | static struct at24_platform_data da830_evm_i2c_eeprom_info = { | 403 | static const struct property_entry da830_evm_i2c_eeprom_properties[] = { |
| 461 | .byte_len = SZ_256K / 8, | 404 | PROPERTY_ENTRY_U32("pagesize", 64), |
| 462 | .page_size = 64, | 405 | { } |
| 463 | .flags = AT24_FLAG_ADDR16, | ||
| 464 | .setup = davinci_get_mac_addr, | ||
| 465 | .context = (void *)0x7f00, | ||
| 466 | }; | 406 | }; |
| 467 | 407 | ||
| 468 | static int __init da830_evm_ui_expander_setup(struct i2c_client *client, | 408 | static int __init da830_evm_ui_expander_setup(struct i2c_client *client, |
| @@ -496,7 +436,7 @@ static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = { | |||
| 496 | static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { | 436 | static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { |
| 497 | { | 437 | { |
| 498 | I2C_BOARD_INFO("24c256", 0x50), | 438 | I2C_BOARD_INFO("24c256", 0x50), |
| 499 | .platform_data = &da830_evm_i2c_eeprom_info, | 439 | .properties = da830_evm_i2c_eeprom_properties, |
| 500 | }, | 440 | }, |
| 501 | { | 441 | { |
| 502 | I2C_BOARD_INFO("tlv320aic3x", 0x18), | 442 | I2C_BOARD_INFO("tlv320aic3x", 0x18), |
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index 44bca048dfd0..56d0e0257048 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
| @@ -150,32 +150,6 @@ static struct spi_board_info da850evm_spi_info[] = { | |||
| 150 | }, | 150 | }, |
| 151 | }; | 151 | }; |
| 152 | 152 | ||
| 153 | #ifdef CONFIG_MTD | ||
| 154 | static void da850_evm_m25p80_notify_add(struct mtd_info *mtd) | ||
| 155 | { | ||
| 156 | char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; | ||
| 157 | size_t retlen; | ||
| 158 | |||
| 159 | if (!strcmp(mtd->name, "MAC-Address")) { | ||
| 160 | mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr); | ||
| 161 | if (retlen == ETH_ALEN) | ||
| 162 | pr_info("Read MAC addr from SPI Flash: %pM\n", | ||
| 163 | mac_addr); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | static struct mtd_notifier da850evm_spi_notifier = { | ||
| 168 | .add = da850_evm_m25p80_notify_add, | ||
| 169 | }; | ||
| 170 | |||
| 171 | static void da850_evm_setup_mac_addr(void) | ||
| 172 | { | ||
| 173 | register_mtd_user(&da850evm_spi_notifier); | ||
| 174 | } | ||
| 175 | #else | ||
| 176 | static void da850_evm_setup_mac_addr(void) { } | ||
| 177 | #endif | ||
| 178 | |||
| 179 | static struct mtd_partition da850_evm_norflash_partition[] = { | 153 | static struct mtd_partition da850_evm_norflash_partition[] = { |
| 180 | { | 154 | { |
| 181 | .name = "bootloaders + env", | 155 | .name = "bootloaders + env", |
| @@ -1064,6 +1038,17 @@ static const short da850_evm_rmii_pins[] = { | |||
| 1064 | -1 | 1038 | -1 |
| 1065 | }; | 1039 | }; |
| 1066 | 1040 | ||
| 1041 | static struct gpiod_hog da850_evm_emac_gpio_hogs[] = { | ||
| 1042 | { | ||
| 1043 | .chip_label = "davinci_gpio", | ||
| 1044 | .chip_hwnum = DA850_MII_MDIO_CLKEN_PIN, | ||
| 1045 | .line_name = "mdio_clk_en", | ||
| 1046 | .lflags = 0, | ||
| 1047 | /* dflags set in da850_evm_config_emac() */ | ||
| 1048 | }, | ||
| 1049 | { } | ||
| 1050 | }; | ||
| 1051 | |||
| 1067 | static int __init da850_evm_config_emac(void) | 1052 | static int __init da850_evm_config_emac(void) |
| 1068 | { | 1053 | { |
| 1069 | void __iomem *cfg_chip3_base; | 1054 | void __iomem *cfg_chip3_base; |
| @@ -1102,14 +1087,9 @@ static int __init da850_evm_config_emac(void) | |||
| 1102 | if (ret) | 1087 | if (ret) |
| 1103 | pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__); | 1088 | pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__); |
| 1104 | 1089 | ||
| 1105 | ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en"); | 1090 | da850_evm_emac_gpio_hogs[0].dflags = rmii_en ? GPIOD_OUT_HIGH |
| 1106 | if (ret) { | 1091 | : GPIOD_OUT_LOW; |
| 1107 | pr_warn("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN); | 1092 | gpiod_add_hogs(da850_evm_emac_gpio_hogs); |
| 1108 | return ret; | ||
| 1109 | } | ||
| 1110 | |||
| 1111 | /* Enable/Disable MII MDIO clock */ | ||
| 1112 | gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en); | ||
| 1113 | 1093 | ||
| 1114 | soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID; | 1094 | soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID; |
| 1115 | 1095 | ||
| @@ -1494,8 +1474,6 @@ static __init void da850_evm_init(void) | |||
| 1494 | if (ret) | 1474 | if (ret) |
| 1495 | pr_warn("%s: SATA registration failed: %d\n", __func__, ret); | 1475 | pr_warn("%s: SATA registration failed: %d\n", __func__, ret); |
| 1496 | 1476 | ||
| 1497 | da850_evm_setup_mac_addr(); | ||
| 1498 | |||
| 1499 | ret = da8xx_register_rproc(); | 1477 | ret = da8xx_register_rproc(); |
| 1500 | if (ret) | 1478 | if (ret) |
| 1501 | pr_warn("%s: dsp/rproc registration failed: %d\n", | 1479 | pr_warn("%s: dsp/rproc registration failed: %d\n", |
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index e3b0b701e395..f21dc8d3b28c 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
| 19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
| 20 | #include <linux/clk.h> | 20 | #include <linux/clk.h> |
| 21 | #include <linux/platform_data/at24.h> | 21 | #include <linux/property.h> |
| 22 | #include <linux/leds.h> | 22 | #include <linux/leds.h> |
| 23 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
| 24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
| @@ -225,18 +225,15 @@ static struct nvmem_cell_lookup davinci_nvmem_cell_lookup = { | |||
| 225 | .con_id = "mac-address", | 225 | .con_id = "mac-address", |
| 226 | }; | 226 | }; |
| 227 | 227 | ||
| 228 | static struct at24_platform_data eeprom_info = { | 228 | static const struct property_entry eeprom_properties[] = { |
| 229 | .byte_len = (256*1024) / 8, | 229 | PROPERTY_ENTRY_U32("pagesize", 64), |
| 230 | .page_size = 64, | 230 | { } |
| 231 | .flags = AT24_FLAG_ADDR16, | ||
| 232 | .setup = davinci_get_mac_addr, | ||
| 233 | .context = (void *)0x7f00, | ||
| 234 | }; | 231 | }; |
| 235 | 232 | ||
| 236 | static struct i2c_board_info i2c_info[] = { | 233 | static struct i2c_board_info i2c_info[] = { |
| 237 | { | 234 | { |
| 238 | I2C_BOARD_INFO("24c256", 0x50), | 235 | I2C_BOARD_INFO("24c256", 0x50), |
| 239 | .platform_data = &eeprom_info, | 236 | .properties = eeprom_properties, |
| 240 | }, | 237 | }, |
| 241 | { | 238 | { |
| 242 | I2C_BOARD_INFO("tlv320aic3x", 0x18), | 239 | I2C_BOARD_INFO("tlv320aic3x", 0x18), |
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index b80c4ee76217..ecd30643c2c4 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c | |||
| @@ -16,8 +16,8 @@ | |||
| 16 | #include <linux/gpio/machine.h> | 16 | #include <linux/gpio/machine.h> |
| 17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
| 18 | #include <linux/platform_data/pcf857x.h> | 18 | #include <linux/platform_data/pcf857x.h> |
| 19 | #include <linux/platform_data/at24.h> | ||
| 20 | #include <linux/platform_data/gpio-davinci.h> | 19 | #include <linux/platform_data/gpio-davinci.h> |
| 20 | #include <linux/property.h> | ||
| 21 | #include <linux/mtd/mtd.h> | 21 | #include <linux/mtd/mtd.h> |
| 22 | #include <linux/mtd/rawnand.h> | 22 | #include <linux/mtd/rawnand.h> |
| 23 | #include <linux/mtd/partitions.h> | 23 | #include <linux/mtd/partitions.h> |
| @@ -532,12 +532,9 @@ static struct nvmem_cell_lookup dm644evm_nvmem_cell_lookup = { | |||
| 532 | .con_id = "mac-address", | 532 | .con_id = "mac-address", |
| 533 | }; | 533 | }; |
| 534 | 534 | ||
| 535 | static struct at24_platform_data eeprom_info = { | 535 | static const struct property_entry eeprom_properties[] = { |
| 536 | .byte_len = (256*1024) / 8, | 536 | PROPERTY_ENTRY_U32("pagesize", 64), |
| 537 | .page_size = 64, | 537 | { } |
| 538 | .flags = AT24_FLAG_ADDR16, | ||
| 539 | .setup = davinci_get_mac_addr, | ||
| 540 | .context = (void *)0x7f00, | ||
| 541 | }; | 538 | }; |
| 542 | 539 | ||
| 543 | /* | 540 | /* |
| @@ -647,7 +644,7 @@ static struct i2c_board_info __initdata i2c_info[] = { | |||
| 647 | }, | 644 | }, |
| 648 | { | 645 | { |
| 649 | I2C_BOARD_INFO("24c256", 0x50), | 646 | I2C_BOARD_INFO("24c256", 0x50), |
| 650 | .platform_data = &eeprom_info, | 647 | .properties = eeprom_properties, |
| 651 | }, | 648 | }, |
| 652 | { | 649 | { |
| 653 | I2C_BOARD_INFO("tlv320aic33", 0x1b), | 650 | I2C_BOARD_INFO("tlv320aic33", 0x1b), |
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index 8d5be6dd2019..02b57face113 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
| 23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
| 25 | #include <linux/platform_data/at24.h> | 25 | #include <linux/property.h> |
| 26 | #include <linux/platform_data/pcf857x.h> | 26 | #include <linux/platform_data/pcf857x.h> |
| 27 | #include <linux/platform_data/ti-aemif.h> | 27 | #include <linux/platform_data/ti-aemif.h> |
| 28 | 28 | ||
| @@ -364,12 +364,9 @@ static struct nvmem_cell_lookup dm646x_evm_nvmem_cell_lookup = { | |||
| 364 | .con_id = "mac-address", | 364 | .con_id = "mac-address", |
| 365 | }; | 365 | }; |
| 366 | 366 | ||
| 367 | static struct at24_platform_data eeprom_info = { | 367 | static const struct property_entry eeprom_properties[] = { |
| 368 | .byte_len = (256*1024) / 8, | 368 | PROPERTY_ENTRY_U32("pagesize", 64), |
| 369 | .page_size = 64, | 369 | { } |
| 370 | .flags = AT24_FLAG_ADDR16, | ||
| 371 | .setup = davinci_get_mac_addr, | ||
| 372 | .context = (void *)0x7f00, | ||
| 373 | }; | 370 | }; |
| 374 | #endif | 371 | #endif |
| 375 | 372 | ||
| @@ -440,7 +437,7 @@ static void evm_init_cpld(void) | |||
| 440 | static struct i2c_board_info __initdata i2c_info[] = { | 437 | static struct i2c_board_info __initdata i2c_info[] = { |
| 441 | { | 438 | { |
| 442 | I2C_BOARD_INFO("24c256", 0x50), | 439 | I2C_BOARD_INFO("24c256", 0x50), |
| 443 | .platform_data = &eeprom_info, | 440 | .properties = eeprom_properties, |
| 444 | }, | 441 | }, |
| 445 | { | 442 | { |
| 446 | I2C_BOARD_INFO("pcf8574a", 0x38), | 443 | I2C_BOARD_INFO("pcf8574a", 0x38), |
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c index 8df16e81b69e..a381b26328d8 100644 --- a/arch/arm/mach-davinci/board-mityomapl138.c +++ b/arch/arm/mach-davinci/board-mityomapl138.c | |||
| @@ -14,11 +14,13 @@ | |||
| 14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| 15 | #include <linux/console.h> | 15 | #include <linux/console.h> |
| 16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/property.h> | ||
| 17 | #include <linux/mtd/partitions.h> | 18 | #include <linux/mtd/partitions.h> |
| 19 | #include <linux/notifier.h> | ||
| 20 | #include <linux/nvmem-consumer.h> | ||
| 18 | #include <linux/nvmem-provider.h> | 21 | #include <linux/nvmem-provider.h> |
| 19 | #include <linux/regulator/machine.h> | 22 | #include <linux/regulator/machine.h> |
| 20 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
| 21 | #include <linux/platform_data/at24.h> | ||
| 22 | #include <linux/etherdevice.h> | 24 | #include <linux/etherdevice.h> |
| 23 | #include <linux/spi/spi.h> | 25 | #include <linux/spi/spi.h> |
| 24 | #include <linux/spi/flash.h> | 26 | #include <linux/spi/flash.h> |
| @@ -117,11 +119,15 @@ static void mityomapl138_cpufreq_init(const char *partnum) | |||
| 117 | static void mityomapl138_cpufreq_init(const char *partnum) { } | 119 | static void mityomapl138_cpufreq_init(const char *partnum) { } |
| 118 | #endif | 120 | #endif |
| 119 | 121 | ||
| 120 | static void read_factory_config(struct nvmem_device *nvmem, void *context) | 122 | static int read_factory_config(struct notifier_block *nb, |
| 123 | unsigned long event, void *data) | ||
| 121 | { | 124 | { |
| 122 | int ret; | 125 | int ret; |
| 123 | const char *partnum = NULL; | 126 | const char *partnum = NULL; |
| 124 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 127 | struct nvmem_device *nvmem = data; |
| 128 | |||
| 129 | if (strcmp(nvmem_dev_name(nvmem), "1-00500") != 0) | ||
| 130 | return NOTIFY_DONE; | ||
| 125 | 131 | ||
| 126 | if (!IS_BUILTIN(CONFIG_NVMEM)) { | 132 | if (!IS_BUILTIN(CONFIG_NVMEM)) { |
| 127 | pr_warn("Factory Config not available without CONFIG_NVMEM\n"); | 133 | pr_warn("Factory Config not available without CONFIG_NVMEM\n"); |
| @@ -147,21 +153,20 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context) | |||
| 147 | goto bad_config; | 153 | goto bad_config; |
| 148 | } | 154 | } |
| 149 | 155 | ||
| 150 | pr_info("Found MAC = %pM\n", factory_config.mac); | ||
| 151 | if (is_valid_ether_addr(factory_config.mac)) | ||
| 152 | memcpy(soc_info->emac_pdata->mac_addr, | ||
| 153 | factory_config.mac, ETH_ALEN); | ||
| 154 | else | ||
| 155 | pr_warn("Invalid MAC found in factory config block\n"); | ||
| 156 | |||
| 157 | partnum = factory_config.partnum; | 156 | partnum = factory_config.partnum; |
| 158 | pr_info("Part Number = %s\n", partnum); | 157 | pr_info("Part Number = %s\n", partnum); |
| 159 | 158 | ||
| 160 | bad_config: | 159 | bad_config: |
| 161 | /* default maximum speed is valid for all platforms */ | 160 | /* default maximum speed is valid for all platforms */ |
| 162 | mityomapl138_cpufreq_init(partnum); | 161 | mityomapl138_cpufreq_init(partnum); |
| 162 | |||
| 163 | return NOTIFY_STOP; | ||
| 163 | } | 164 | } |
| 164 | 165 | ||
| 166 | static struct notifier_block mityomapl138_nvmem_notifier = { | ||
| 167 | .notifier_call = read_factory_config, | ||
| 168 | }; | ||
| 169 | |||
| 165 | /* | 170 | /* |
| 166 | * We don't define a cell for factory config as it will be accessed from the | 171 | * We don't define a cell for factory config as it will be accessed from the |
| 167 | * board file using the nvmem notifier chain. | 172 | * board file using the nvmem notifier chain. |
| @@ -187,12 +192,10 @@ static struct nvmem_cell_lookup mityomapl138_nvmem_cell_lookup = { | |||
| 187 | .con_id = "mac-address", | 192 | .con_id = "mac-address", |
| 188 | }; | 193 | }; |
| 189 | 194 | ||
| 190 | static struct at24_platform_data mityomapl138_fd_chip = { | 195 | static const struct property_entry mityomapl138_fd_chip_properties[] = { |
| 191 | .byte_len = 256, | 196 | PROPERTY_ENTRY_U32("pagesize", 8), |
| 192 | .page_size = 8, | 197 | PROPERTY_ENTRY_BOOL("read-only"), |
| 193 | .flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO, | 198 | { } |
| 194 | .setup = read_factory_config, | ||
| 195 | .context = NULL, | ||
| 196 | }; | 199 | }; |
| 197 | 200 | ||
| 198 | static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { | 201 | static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { |
| @@ -321,7 +324,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = { | |||
| 321 | }, | 324 | }, |
| 322 | { | 325 | { |
| 323 | I2C_BOARD_INFO("24c02", 0x50), | 326 | I2C_BOARD_INFO("24c02", 0x50), |
| 324 | .platform_data = &mityomapl138_fd_chip, | 327 | .properties = mityomapl138_fd_chip_properties, |
| 325 | }, | 328 | }, |
| 326 | }; | 329 | }; |
| 327 | 330 | ||
| @@ -569,6 +572,7 @@ static void __init mityomapl138_init(void) | |||
| 569 | 572 | ||
| 570 | davinci_serial_init(da8xx_serial_device); | 573 | davinci_serial_init(da8xx_serial_device); |
| 571 | 574 | ||
| 575 | nvmem_register_notifier(&mityomapl138_nvmem_notifier); | ||
| 572 | nvmem_add_cell_table(&mityomapl138_nvmem_cell_table); | 576 | nvmem_add_cell_table(&mityomapl138_nvmem_cell_table); |
| 573 | nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1); | 577 | nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1); |
| 574 | 578 | ||
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c index 94c4f126ef86..88a0c62eee86 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c | |||
| @@ -294,66 +294,24 @@ static int omapl138_hawk_register_aemif(void) | |||
| 294 | return platform_device_register(&omapl138_hawk_aemif_device); | 294 | return platform_device_register(&omapl138_hawk_aemif_device); |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id); | ||
| 298 | static da8xx_ocic_handler_t hawk_usb_ocic_handler; | ||
| 299 | |||
| 300 | static const short da850_hawk_usb11_pins[] = { | 297 | static const short da850_hawk_usb11_pins[] = { |
| 301 | DA850_GPIO2_4, DA850_GPIO6_13, | 298 | DA850_GPIO2_4, DA850_GPIO6_13, |
| 302 | -1 | 299 | -1 |
| 303 | }; | 300 | }; |
| 304 | 301 | ||
| 305 | static int hawk_usb_set_power(unsigned port, int on) | 302 | static struct gpiod_lookup_table hawk_usb_gpio_lookup = { |
| 306 | { | 303 | .dev_id = "ohci-da8xx", |
| 307 | gpio_set_value(DA850_USB1_VBUS_PIN, on); | 304 | .table = { |
| 308 | return 0; | 305 | GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, "vbus", 0), |
| 309 | } | 306 | GPIO_LOOKUP("davinci_gpio", DA850_USB1_OC_PIN, "oc", 0), |
| 310 | 307 | }, | |
| 311 | static int hawk_usb_get_power(unsigned port) | 308 | }; |
| 312 | { | ||
| 313 | return gpio_get_value(DA850_USB1_VBUS_PIN); | ||
| 314 | } | ||
| 315 | |||
| 316 | static int hawk_usb_get_oci(unsigned port) | ||
| 317 | { | ||
| 318 | return !gpio_get_value(DA850_USB1_OC_PIN); | ||
| 319 | } | ||
| 320 | |||
| 321 | static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler) | ||
| 322 | { | ||
| 323 | int irq = gpio_to_irq(DA850_USB1_OC_PIN); | ||
| 324 | int error = 0; | ||
| 325 | |||
| 326 | if (handler != NULL) { | ||
| 327 | hawk_usb_ocic_handler = handler; | ||
| 328 | |||
| 329 | error = request_irq(irq, omapl138_hawk_usb_ocic_irq, | ||
| 330 | IRQF_TRIGGER_RISING | | ||
| 331 | IRQF_TRIGGER_FALLING, | ||
| 332 | "OHCI over-current indicator", NULL); | ||
| 333 | if (error) | ||
| 334 | pr_err("%s: could not request IRQ to watch " | ||
| 335 | "over-current indicator changes\n", __func__); | ||
| 336 | } else { | ||
| 337 | free_irq(irq, NULL); | ||
| 338 | } | ||
| 339 | return error; | ||
| 340 | } | ||
| 341 | 309 | ||
| 342 | static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = { | 310 | static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = { |
| 343 | .set_power = hawk_usb_set_power, | ||
| 344 | .get_power = hawk_usb_get_power, | ||
| 345 | .get_oci = hawk_usb_get_oci, | ||
| 346 | .ocic_notify = hawk_usb_ocic_notify, | ||
| 347 | /* TPS2087 switch @ 5V */ | 311 | /* TPS2087 switch @ 5V */ |
| 348 | .potpgt = (3 + 1) / 2, /* 3 ms max */ | 312 | .potpgt = (3 + 1) / 2, /* 3 ms max */ |
| 349 | }; | 313 | }; |
| 350 | 314 | ||
| 351 | static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id) | ||
| 352 | { | ||
| 353 | hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata, 1); | ||
| 354 | return IRQ_HANDLED; | ||
| 355 | } | ||
| 356 | |||
| 357 | static __init void omapl138_hawk_usb_init(void) | 315 | static __init void omapl138_hawk_usb_init(void) |
| 358 | { | 316 | { |
| 359 | int ret; | 317 | int ret; |
| @@ -374,34 +332,13 @@ static __init void omapl138_hawk_usb_init(void) | |||
| 374 | pr_warn("%s: USB PHY registration failed: %d\n", | 332 | pr_warn("%s: USB PHY registration failed: %d\n", |
| 375 | __func__, ret); | 333 | __func__, ret); |
| 376 | 334 | ||
| 377 | ret = gpio_request_one(DA850_USB1_VBUS_PIN, | 335 | gpiod_add_lookup_table(&hawk_usb_gpio_lookup); |
| 378 | GPIOF_DIR_OUT, "USB1 VBUS"); | ||
| 379 | if (ret < 0) { | ||
| 380 | pr_err("%s: failed to request GPIO for USB 1.1 port " | ||
| 381 | "power control: %d\n", __func__, ret); | ||
| 382 | return; | ||
| 383 | } | ||
| 384 | |||
| 385 | ret = gpio_request_one(DA850_USB1_OC_PIN, | ||
| 386 | GPIOF_DIR_IN, "USB1 OC"); | ||
| 387 | if (ret < 0) { | ||
| 388 | pr_err("%s: failed to request GPIO for USB 1.1 port " | ||
| 389 | "over-current indicator: %d\n", __func__, ret); | ||
| 390 | goto usb11_setup_oc_fail; | ||
| 391 | } | ||
| 392 | 336 | ||
| 393 | ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata); | 337 | ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata); |
| 394 | if (ret) { | 338 | if (ret) |
| 395 | pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret); | 339 | pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret); |
| 396 | goto usb11_setup_fail; | ||
| 397 | } | ||
| 398 | 340 | ||
| 399 | return; | 341 | return; |
| 400 | |||
| 401 | usb11_setup_fail: | ||
| 402 | gpio_free(DA850_USB1_OC_PIN); | ||
| 403 | usb11_setup_oc_fail: | ||
| 404 | gpio_free(DA850_USB1_VBUS_PIN); | ||
| 405 | } | 342 | } |
| 406 | 343 | ||
| 407 | static __init void omapl138_hawk_init(void) | 344 | static __init void omapl138_hawk_init(void) |
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c index 792bb84d5011..ff14de1396c8 100644 --- a/arch/arm/mach-davinci/board-sffsdr.c +++ b/arch/arm/mach-davinci/board-sffsdr.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
| 27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
| 29 | #include <linux/platform_data/at24.h> | 29 | #include <linux/property.h> |
| 30 | #include <linux/mtd/mtd.h> | 30 | #include <linux/mtd/mtd.h> |
| 31 | #include <linux/mtd/rawnand.h> | 31 | #include <linux/mtd/rawnand.h> |
| 32 | #include <linux/mtd/partitions.h> | 32 | #include <linux/mtd/partitions.h> |
| @@ -92,16 +92,15 @@ static struct platform_device davinci_sffsdr_nandflash_device = { | |||
| 92 | .resource = davinci_sffsdr_nandflash_resource, | 92 | .resource = davinci_sffsdr_nandflash_resource, |
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | static struct at24_platform_data eeprom_info = { | 95 | static const struct property_entry eeprom_properties[] = { |
| 96 | .byte_len = (64*1024) / 8, | 96 | PROPERTY_ENTRY_U32("pagesize", 32), |
| 97 | .page_size = 32, | 97 | { } |
| 98 | .flags = AT24_FLAG_ADDR16, | ||
| 99 | }; | 98 | }; |
| 100 | 99 | ||
| 101 | static struct i2c_board_info __initdata i2c_info[] = { | 100 | static struct i2c_board_info __initdata i2c_info[] = { |
| 102 | { | 101 | { |
| 103 | I2C_BOARD_INFO("24lc64", 0x50), | 102 | I2C_BOARD_INFO("24c64", 0x50), |
| 104 | .platform_data = &eeprom_info, | 103 | .properties = eeprom_properties, |
| 105 | }, | 104 | }, |
| 106 | /* Other I2C devices: | 105 | /* Other I2C devices: |
| 107 | * MSP430, addr 0x23 (not used) | 106 | * MSP430, addr 0x23 (not used) |
diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c index e1d0f0d841ff..0c638fe15dcb 100644 --- a/arch/arm/mach-davinci/common.c +++ b/arch/arm/mach-davinci/common.c | |||
| @@ -26,21 +26,6 @@ EXPORT_SYMBOL(davinci_soc_info); | |||
| 26 | void __iomem *davinci_intc_base; | 26 | void __iomem *davinci_intc_base; |
| 27 | int davinci_intc_type; | 27 | int davinci_intc_type; |
| 28 | 28 | ||
| 29 | void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context) | ||
| 30 | { | ||
| 31 | char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; | ||
| 32 | off_t offset = (off_t)context; | ||
| 33 | |||
| 34 | if (!IS_BUILTIN(CONFIG_NVMEM)) { | ||
| 35 | pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n"); | ||
| 36 | return; | ||
| 37 | } | ||
| 38 | |||
| 39 | /* Read MAC addr from EEPROM */ | ||
| 40 | if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN) | ||
| 41 | pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); | ||
| 42 | } | ||
| 43 | |||
| 44 | static int __init davinci_init_id(struct davinci_soc_info *soc_info) | 29 | static int __init davinci_init_id(struct davinci_soc_info *soc_info) |
| 45 | { | 30 | { |
| 46 | int i; | 31 | int i; |
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index a55cbba40a5a..ca8a94f15ac0 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #include <linux/clk.h> | 11 | #include <linux/clk.h> |
| 12 | #include <linux/gpio/consumer.h> | ||
| 12 | #include <linux/io.h> | 13 | #include <linux/io.h> |
| 13 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
| 14 | #include <linux/jiffies.h> | 15 | #include <linux/jiffies.h> |
| @@ -40,6 +41,8 @@ struct da8xx_ohci_hcd { | |||
| 40 | struct regulator *vbus_reg; | 41 | struct regulator *vbus_reg; |
| 41 | struct notifier_block nb; | 42 | struct notifier_block nb; |
| 42 | unsigned int reg_enabled; | 43 | unsigned int reg_enabled; |
| 44 | struct gpio_desc *vbus_gpio; | ||
| 45 | struct gpio_desc *oc_gpio; | ||
| 43 | }; | 46 | }; |
| 44 | 47 | ||
| 45 | #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv) | 48 | #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv) |
| @@ -86,12 +89,13 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd) | |||
| 86 | static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on) | 89 | static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on) |
| 87 | { | 90 | { |
| 88 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); | 91 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); |
| 89 | struct device *dev = hcd->self.controller; | 92 | struct device *dev = hcd->self.controller; |
| 90 | struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev); | ||
| 91 | int ret; | 93 | int ret; |
| 92 | 94 | ||
| 93 | if (hub && hub->set_power) | 95 | if (da8xx_ohci->vbus_gpio) { |
| 94 | return hub->set_power(1, on); | 96 | gpiod_set_value_cansleep(da8xx_ohci->vbus_gpio, on); |
| 97 | return 0; | ||
| 98 | } | ||
| 95 | 99 | ||
| 96 | if (!da8xx_ohci->vbus_reg) | 100 | if (!da8xx_ohci->vbus_reg) |
| 97 | return 0; | 101 | return 0; |
| @@ -119,11 +123,9 @@ static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on) | |||
| 119 | static int ohci_da8xx_get_power(struct usb_hcd *hcd) | 123 | static int ohci_da8xx_get_power(struct usb_hcd *hcd) |
| 120 | { | 124 | { |
| 121 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); | 125 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); |
| 122 | struct device *dev = hcd->self.controller; | ||
| 123 | struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev); | ||
| 124 | 126 | ||
| 125 | if (hub && hub->get_power) | 127 | if (da8xx_ohci->vbus_gpio) |
| 126 | return hub->get_power(1); | 128 | return gpiod_get_value_cansleep(da8xx_ohci->vbus_gpio); |
| 127 | 129 | ||
| 128 | if (da8xx_ohci->vbus_reg) | 130 | if (da8xx_ohci->vbus_reg) |
| 129 | return regulator_is_enabled(da8xx_ohci->vbus_reg); | 131 | return regulator_is_enabled(da8xx_ohci->vbus_reg); |
| @@ -134,13 +136,11 @@ static int ohci_da8xx_get_power(struct usb_hcd *hcd) | |||
| 134 | static int ohci_da8xx_get_oci(struct usb_hcd *hcd) | 136 | static int ohci_da8xx_get_oci(struct usb_hcd *hcd) |
| 135 | { | 137 | { |
| 136 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); | 138 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); |
| 137 | struct device *dev = hcd->self.controller; | ||
| 138 | struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev); | ||
| 139 | unsigned int flags; | 139 | unsigned int flags; |
| 140 | int ret; | 140 | int ret; |
| 141 | 141 | ||
| 142 | if (hub && hub->get_oci) | 142 | if (da8xx_ohci->oc_gpio) |
| 143 | return hub->get_oci(1); | 143 | return gpiod_get_value_cansleep(da8xx_ohci->oc_gpio); |
| 144 | 144 | ||
| 145 | if (!da8xx_ohci->vbus_reg) | 145 | if (!da8xx_ohci->vbus_reg) |
| 146 | return 0; | 146 | return 0; |
| @@ -158,10 +158,8 @@ static int ohci_da8xx_get_oci(struct usb_hcd *hcd) | |||
| 158 | static int ohci_da8xx_has_set_power(struct usb_hcd *hcd) | 158 | static int ohci_da8xx_has_set_power(struct usb_hcd *hcd) |
| 159 | { | 159 | { |
| 160 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); | 160 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); |
| 161 | struct device *dev = hcd->self.controller; | ||
| 162 | struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev); | ||
| 163 | 161 | ||
| 164 | if (hub && hub->set_power) | 162 | if (da8xx_ohci->vbus_gpio) |
| 165 | return 1; | 163 | return 1; |
| 166 | 164 | ||
| 167 | if (da8xx_ohci->vbus_reg) | 165 | if (da8xx_ohci->vbus_reg) |
| @@ -173,10 +171,8 @@ static int ohci_da8xx_has_set_power(struct usb_hcd *hcd) | |||
| 173 | static int ohci_da8xx_has_oci(struct usb_hcd *hcd) | 171 | static int ohci_da8xx_has_oci(struct usb_hcd *hcd) |
| 174 | { | 172 | { |
| 175 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); | 173 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); |
| 176 | struct device *dev = hcd->self.controller; | ||
| 177 | struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev); | ||
| 178 | 174 | ||
| 179 | if (hub && hub->get_oci) | 175 | if (da8xx_ohci->oc_gpio) |
| 180 | return 1; | 176 | return 1; |
| 181 | 177 | ||
| 182 | if (da8xx_ohci->vbus_reg) | 178 | if (da8xx_ohci->vbus_reg) |
| @@ -196,19 +192,6 @@ static int ohci_da8xx_has_potpgt(struct usb_hcd *hcd) | |||
| 196 | return 0; | 192 | return 0; |
| 197 | } | 193 | } |
| 198 | 194 | ||
| 199 | /* | ||
| 200 | * Handle the port over-current indicator change. | ||
| 201 | */ | ||
| 202 | static void ohci_da8xx_ocic_handler(struct da8xx_ohci_root_hub *hub, | ||
| 203 | unsigned port) | ||
| 204 | { | ||
| 205 | ocic_mask |= 1 << port; | ||
| 206 | |||
| 207 | /* Once over-current is detected, the port needs to be powered down */ | ||
| 208 | if (hub->get_oci(port) > 0) | ||
| 209 | hub->set_power(port, 0); | ||
| 210 | } | ||
| 211 | |||
| 212 | static int ohci_da8xx_regulator_event(struct notifier_block *nb, | 195 | static int ohci_da8xx_regulator_event(struct notifier_block *nb, |
| 213 | unsigned long event, void *data) | 196 | unsigned long event, void *data) |
| 214 | { | 197 | { |
| @@ -223,16 +206,23 @@ static int ohci_da8xx_regulator_event(struct notifier_block *nb, | |||
| 223 | return 0; | 206 | return 0; |
| 224 | } | 207 | } |
| 225 | 208 | ||
| 209 | static irqreturn_t ohci_da8xx_oc_handler(int irq, void *data) | ||
| 210 | { | ||
| 211 | struct da8xx_ohci_hcd *da8xx_ohci = data; | ||
| 212 | |||
| 213 | if (gpiod_get_value(da8xx_ohci->oc_gpio)) | ||
| 214 | gpiod_set_value(da8xx_ohci->vbus_gpio, 0); | ||
| 215 | |||
| 216 | return IRQ_HANDLED; | ||
| 217 | } | ||
| 218 | |||
| 226 | static int ohci_da8xx_register_notify(struct usb_hcd *hcd) | 219 | static int ohci_da8xx_register_notify(struct usb_hcd *hcd) |
| 227 | { | 220 | { |
| 228 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); | 221 | struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd); |
| 229 | struct device *dev = hcd->self.controller; | 222 | struct device *dev = hcd->self.controller; |
| 230 | struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev); | ||
| 231 | int ret = 0; | 223 | int ret = 0; |
| 232 | 224 | ||
| 233 | if (hub && hub->ocic_notify) { | 225 | if (!da8xx_ohci->oc_gpio && da8xx_ohci->vbus_reg) { |
| 234 | ret = hub->ocic_notify(ohci_da8xx_ocic_handler); | ||
| 235 | } else if (da8xx_ohci->vbus_reg) { | ||
| 236 | da8xx_ohci->nb.notifier_call = ohci_da8xx_regulator_event; | 226 | da8xx_ohci->nb.notifier_call = ohci_da8xx_regulator_event; |
| 237 | ret = devm_regulator_register_notifier(da8xx_ohci->vbus_reg, | 227 | ret = devm_regulator_register_notifier(da8xx_ohci->vbus_reg, |
| 238 | &da8xx_ohci->nb); | 228 | &da8xx_ohci->nb); |
| @@ -244,15 +234,6 @@ static int ohci_da8xx_register_notify(struct usb_hcd *hcd) | |||
| 244 | return ret; | 234 | return ret; |
| 245 | } | 235 | } |
| 246 | 236 | ||
| 247 | static void ohci_da8xx_unregister_notify(struct usb_hcd *hcd) | ||
| 248 | { | ||
| 249 | struct device *dev = hcd->self.controller; | ||
| 250 | struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev); | ||
| 251 | |||
| 252 | if (hub && hub->ocic_notify) | ||
| 253 | hub->ocic_notify(NULL); | ||
| 254 | } | ||
| 255 | |||
| 256 | static int ohci_da8xx_reset(struct usb_hcd *hcd) | 237 | static int ohci_da8xx_reset(struct usb_hcd *hcd) |
| 257 | { | 238 | { |
| 258 | struct device *dev = hcd->self.controller; | 239 | struct device *dev = hcd->self.controller; |
| @@ -402,34 +383,35 @@ MODULE_DEVICE_TABLE(of, da8xx_ohci_ids); | |||
| 402 | static int ohci_da8xx_probe(struct platform_device *pdev) | 383 | static int ohci_da8xx_probe(struct platform_device *pdev) |
| 403 | { | 384 | { |
| 404 | struct da8xx_ohci_hcd *da8xx_ohci; | 385 | struct da8xx_ohci_hcd *da8xx_ohci; |
| 386 | struct device *dev = &pdev->dev; | ||
| 387 | int error, hcd_irq, oc_irq; | ||
| 405 | struct usb_hcd *hcd; | 388 | struct usb_hcd *hcd; |
| 406 | struct resource *mem; | 389 | struct resource *mem; |
| 407 | int error, irq; | 390 | |
| 408 | hcd = usb_create_hcd(&ohci_da8xx_hc_driver, &pdev->dev, | 391 | hcd = usb_create_hcd(&ohci_da8xx_hc_driver, dev, dev_name(dev)); |
| 409 | dev_name(&pdev->dev)); | ||
| 410 | if (!hcd) | 392 | if (!hcd) |
| 411 | return -ENOMEM; | 393 | return -ENOMEM; |
| 412 | 394 | ||
| 413 | da8xx_ohci = to_da8xx_ohci(hcd); | 395 | da8xx_ohci = to_da8xx_ohci(hcd); |
| 414 | da8xx_ohci->hcd = hcd; | 396 | da8xx_ohci->hcd = hcd; |
| 415 | 397 | ||
| 416 | da8xx_ohci->usb11_clk = devm_clk_get(&pdev->dev, NULL); | 398 | da8xx_ohci->usb11_clk = devm_clk_get(dev, NULL); |
| 417 | if (IS_ERR(da8xx_ohci->usb11_clk)) { | 399 | if (IS_ERR(da8xx_ohci->usb11_clk)) { |
| 418 | error = PTR_ERR(da8xx_ohci->usb11_clk); | 400 | error = PTR_ERR(da8xx_ohci->usb11_clk); |
| 419 | if (error != -EPROBE_DEFER) | 401 | if (error != -EPROBE_DEFER) |
| 420 | dev_err(&pdev->dev, "Failed to get clock.\n"); | 402 | dev_err(dev, "Failed to get clock.\n"); |
| 421 | goto err; | 403 | goto err; |
| 422 | } | 404 | } |
| 423 | 405 | ||
| 424 | da8xx_ohci->usb11_phy = devm_phy_get(&pdev->dev, "usb-phy"); | 406 | da8xx_ohci->usb11_phy = devm_phy_get(dev, "usb-phy"); |
| 425 | if (IS_ERR(da8xx_ohci->usb11_phy)) { | 407 | if (IS_ERR(da8xx_ohci->usb11_phy)) { |
| 426 | error = PTR_ERR(da8xx_ohci->usb11_phy); | 408 | error = PTR_ERR(da8xx_ohci->usb11_phy); |
| 427 | if (error != -EPROBE_DEFER) | 409 | if (error != -EPROBE_DEFER) |
| 428 | dev_err(&pdev->dev, "Failed to get phy.\n"); | 410 | dev_err(dev, "Failed to get phy.\n"); |
| 429 | goto err; | 411 | goto err; |
| 430 | } | 412 | } |
| 431 | 413 | ||
| 432 | da8xx_ohci->vbus_reg = devm_regulator_get_optional(&pdev->dev, "vbus"); | 414 | da8xx_ohci->vbus_reg = devm_regulator_get_optional(dev, "vbus"); |
| 433 | if (IS_ERR(da8xx_ohci->vbus_reg)) { | 415 | if (IS_ERR(da8xx_ohci->vbus_reg)) { |
| 434 | error = PTR_ERR(da8xx_ohci->vbus_reg); | 416 | error = PTR_ERR(da8xx_ohci->vbus_reg); |
| 435 | if (error == -ENODEV) { | 417 | if (error == -ENODEV) { |
| @@ -437,13 +419,34 @@ static int ohci_da8xx_probe(struct platform_device *pdev) | |||
| 437 | } else if (error == -EPROBE_DEFER) { | 419 | } else if (error == -EPROBE_DEFER) { |
| 438 | goto err; | 420 | goto err; |
| 439 | } else { | 421 | } else { |
| 440 | dev_err(&pdev->dev, "Failed to get regulator\n"); | 422 | dev_err(dev, "Failed to get regulator\n"); |
| 441 | goto err; | 423 | goto err; |
| 442 | } | 424 | } |
| 443 | } | 425 | } |
| 444 | 426 | ||
| 427 | da8xx_ohci->vbus_gpio = devm_gpiod_get_optional(dev, "vbus", | ||
| 428 | GPIOD_OUT_HIGH); | ||
| 429 | if (IS_ERR(da8xx_ohci->vbus_gpio)) | ||
| 430 | goto err; | ||
| 431 | |||
| 432 | da8xx_ohci->oc_gpio = devm_gpiod_get_optional(dev, "oc", GPIOD_IN); | ||
| 433 | if (IS_ERR(da8xx_ohci->oc_gpio)) | ||
| 434 | goto err; | ||
| 435 | |||
| 436 | if (da8xx_ohci->oc_gpio) { | ||
| 437 | oc_irq = gpiod_to_irq(da8xx_ohci->oc_gpio); | ||
| 438 | if (oc_irq < 0) | ||
| 439 | goto err; | ||
| 440 | |||
| 441 | error = devm_request_irq(dev, oc_irq, ohci_da8xx_oc_handler, | ||
| 442 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | ||
| 443 | "OHCI over-current indicator", da8xx_ohci); | ||
| 444 | if (error) | ||
| 445 | goto err; | ||
| 446 | } | ||
| 447 | |||
| 445 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 448 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 446 | hcd->regs = devm_ioremap_resource(&pdev->dev, mem); | 449 | hcd->regs = devm_ioremap_resource(dev, mem); |
| 447 | if (IS_ERR(hcd->regs)) { | 450 | if (IS_ERR(hcd->regs)) { |
| 448 | error = PTR_ERR(hcd->regs); | 451 | error = PTR_ERR(hcd->regs); |
| 449 | goto err; | 452 | goto err; |
| @@ -451,13 +454,13 @@ static int ohci_da8xx_probe(struct platform_device *pdev) | |||
| 451 | hcd->rsrc_start = mem->start; | 454 | hcd->rsrc_start = mem->start; |
| 452 | hcd->rsrc_len = resource_size(mem); | 455 | hcd->rsrc_len = resource_size(mem); |
| 453 | 456 | ||
| 454 | irq = platform_get_irq(pdev, 0); | 457 | hcd_irq = platform_get_irq(pdev, 0); |
| 455 | if (irq < 0) { | 458 | if (hcd_irq < 0) { |
| 456 | error = -ENODEV; | 459 | error = -ENODEV; |
| 457 | goto err; | 460 | goto err; |
| 458 | } | 461 | } |
| 459 | 462 | ||
| 460 | error = usb_add_hcd(hcd, irq, 0); | 463 | error = usb_add_hcd(hcd, hcd_irq, 0); |
| 461 | if (error) | 464 | if (error) |
| 462 | goto err; | 465 | goto err; |
| 463 | 466 | ||
| @@ -480,7 +483,6 @@ static int ohci_da8xx_remove(struct platform_device *pdev) | |||
| 480 | { | 483 | { |
| 481 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 484 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 482 | 485 | ||
| 483 | ohci_da8xx_unregister_notify(hcd); | ||
| 484 | usb_remove_hcd(hcd); | 486 | usb_remove_hcd(hcd); |
| 485 | usb_put_hcd(hcd); | 487 | usb_put_hcd(hcd); |
| 486 | 488 | ||
diff --git a/include/linux/davinci_emac.h b/include/linux/davinci_emac.h index 05b97144d342..28e6cf1356da 100644 --- a/include/linux/davinci_emac.h +++ b/include/linux/davinci_emac.h | |||
| @@ -46,5 +46,4 @@ enum { | |||
| 46 | EMAC_VERSION_2, /* DM646x */ | 46 | EMAC_VERSION_2, /* DM646x */ |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context); | ||
| 50 | #endif | 49 | #endif |
diff --git a/include/linux/platform_data/usb-davinci.h b/include/linux/platform_data/usb-davinci.h index 0926e99f2e8f..879f5c78b91a 100644 --- a/include/linux/platform_data/usb-davinci.h +++ b/include/linux/platform_data/usb-davinci.h | |||
| @@ -11,22 +11,8 @@ | |||
| 11 | #ifndef __ASM_ARCH_USB_H | 11 | #ifndef __ASM_ARCH_USB_H |
| 12 | #define __ASM_ARCH_USB_H | 12 | #define __ASM_ARCH_USB_H |
| 13 | 13 | ||
| 14 | struct da8xx_ohci_root_hub; | ||
| 15 | |||
| 16 | typedef void (*da8xx_ocic_handler_t)(struct da8xx_ohci_root_hub *hub, | ||
| 17 | unsigned port); | ||
| 18 | |||
| 19 | /* Passed as the platform data to the OHCI driver */ | 14 | /* Passed as the platform data to the OHCI driver */ |
| 20 | struct da8xx_ohci_root_hub { | 15 | struct da8xx_ohci_root_hub { |
| 21 | /* Switch the port power on/off */ | ||
| 22 | int (*set_power)(unsigned port, int on); | ||
| 23 | /* Read the port power status */ | ||
| 24 | int (*get_power)(unsigned port); | ||
| 25 | /* Read the port over-current indicator */ | ||
| 26 | int (*get_oci)(unsigned port); | ||
| 27 | /* Over-current indicator change notification (pass NULL to disable) */ | ||
| 28 | int (*ocic_notify)(da8xx_ocic_handler_t handler); | ||
| 29 | |||
| 30 | /* Time from power on to power good (in 2 ms units) */ | 16 | /* Time from power on to power good (in 2 ms units) */ |
| 31 | u8 potpgt; | 17 | u8 potpgt; |
| 32 | }; | 18 | }; |
