diff options
-rw-r--r-- | drivers/net/phy/phy_device.c | 12 | ||||
-rw-r--r-- | include/linux/mod_devicetable.h | 26 | ||||
-rw-r--r-- | include/linux/phy.h | 1 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 26 |
4 files changed, 65 insertions, 0 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index db1794546c56..1a99bb244106 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
@@ -149,6 +149,7 @@ EXPORT_SYMBOL(phy_scan_fixups); | |||
149 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) | 149 | struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) |
150 | { | 150 | { |
151 | struct phy_device *dev; | 151 | struct phy_device *dev; |
152 | |||
152 | /* We allocate the device, and initialize the | 153 | /* We allocate the device, and initialize the |
153 | * default values */ | 154 | * default values */ |
154 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 155 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
@@ -179,6 +180,17 @@ struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id) | |||
179 | mutex_init(&dev->lock); | 180 | mutex_init(&dev->lock); |
180 | INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); | 181 | INIT_DELAYED_WORK(&dev->state_queue, phy_state_machine); |
181 | 182 | ||
183 | /* Request the appropriate module unconditionally; don't | ||
184 | bother trying to do so only if it isn't already loaded, | ||
185 | because that gets complicated. A hotplug event would have | ||
186 | done an unconditional modprobe anyway. | ||
187 | We don't do normal hotplug because it won't work for MDIO | ||
188 | -- because it relies on the device staying around for long | ||
189 | enough for the driver to get loaded. With MDIO, the NIC | ||
190 | driver will get bored and give up as soon as it finds that | ||
191 | there's no driver _already_ loaded. */ | ||
192 | request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT, MDIO_ID_ARGS(phy_id)); | ||
193 | |||
182 | return dev; | 194 | return dev; |
183 | } | 195 | } |
184 | EXPORT_SYMBOL(phy_device_create); | 196 | EXPORT_SYMBOL(phy_device_create); |
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index f58e9d836f32..55f1f9c9506c 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h | |||
@@ -474,4 +474,30 @@ struct platform_device_id { | |||
474 | __attribute__((aligned(sizeof(kernel_ulong_t)))); | 474 | __attribute__((aligned(sizeof(kernel_ulong_t)))); |
475 | }; | 475 | }; |
476 | 476 | ||
477 | #define MDIO_MODULE_PREFIX "mdio:" | ||
478 | |||
479 | #define MDIO_ID_FMT "%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d" | ||
480 | #define MDIO_ID_ARGS(_id) \ | ||
481 | (_id)>>31, ((_id)>>30) & 1, ((_id)>>29) & 1, ((_id)>>28) & 1, \ | ||
482 | ((_id)>>27) & 1, ((_id)>>26) & 1, ((_id)>>25) & 1, ((_id)>>24) & 1, \ | ||
483 | ((_id)>>23) & 1, ((_id)>>22) & 1, ((_id)>>21) & 1, ((_id)>>20) & 1, \ | ||
484 | ((_id)>>19) & 1, ((_id)>>18) & 1, ((_id)>>17) & 1, ((_id)>>16) & 1, \ | ||
485 | ((_id)>>15) & 1, ((_id)>>14) & 1, ((_id)>>13) & 1, ((_id)>>12) & 1, \ | ||
486 | ((_id)>>11) & 1, ((_id)>>10) & 1, ((_id)>>9) & 1, ((_id)>>8) & 1, \ | ||
487 | ((_id)>>7) & 1, ((_id)>>6) & 1, ((_id)>>5) & 1, ((_id)>>4) & 1, \ | ||
488 | ((_id)>>3) & 1, ((_id)>>2) & 1, ((_id)>>1) & 1, (_id) & 1 | ||
489 | |||
490 | /** | ||
491 | * struct mdio_device_id - identifies PHY devices on an MDIO/MII bus | ||
492 | * @phy_id: The result of | ||
493 | * (mdio_read(&MII_PHYSID1) << 16 | mdio_read(&PHYSID2)) & @phy_id_mask | ||
494 | * for this PHY type | ||
495 | * @phy_id_mask: Defines the significant bits of @phy_id. A value of 0 | ||
496 | * is used to terminate an array of struct mdio_device_id. | ||
497 | */ | ||
498 | struct mdio_device_id { | ||
499 | __u32 phy_id; | ||
500 | __u32 phy_id_mask; | ||
501 | }; | ||
502 | |||
477 | #endif /* LINUX_MOD_DEVICETABLE_H */ | 503 | #endif /* LINUX_MOD_DEVICETABLE_H */ |
diff --git a/include/linux/phy.h b/include/linux/phy.h index d9bce4b526b4..987e111f7b11 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/mii.h> | 24 | #include <linux/mii.h> |
25 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
26 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
27 | #include <linux/mod_devicetable.h> | ||
27 | 28 | ||
28 | #include <asm/atomic.h> | 29 | #include <asm/atomic.h> |
29 | 30 | ||
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 220213e603db..36a60a853173 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -796,6 +796,28 @@ static int do_platform_entry(const char *filename, | |||
796 | return 1; | 796 | return 1; |
797 | } | 797 | } |
798 | 798 | ||
799 | static int do_mdio_entry(const char *filename, | ||
800 | struct mdio_device_id *id, char *alias) | ||
801 | { | ||
802 | int i; | ||
803 | |||
804 | alias += sprintf(alias, MDIO_MODULE_PREFIX); | ||
805 | |||
806 | for (i = 0; i < 32; i++) { | ||
807 | if (!((id->phy_id_mask >> (31-i)) & 1)) | ||
808 | *(alias++) = '?'; | ||
809 | else if ((id->phy_id >> (31-i)) & 1) | ||
810 | *(alias++) = '1'; | ||
811 | else | ||
812 | *(alias++) = '0'; | ||
813 | } | ||
814 | |||
815 | /* Terminate the string */ | ||
816 | *alias = 0; | ||
817 | |||
818 | return 1; | ||
819 | } | ||
820 | |||
799 | /* Ignore any prefix, eg. some architectures prepend _ */ | 821 | /* Ignore any prefix, eg. some architectures prepend _ */ |
800 | static inline int sym_is(const char *symbol, const char *name) | 822 | static inline int sym_is(const char *symbol, const char *name) |
801 | { | 823 | { |
@@ -943,6 +965,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
943 | do_table(symval, sym->st_size, | 965 | do_table(symval, sym->st_size, |
944 | sizeof(struct platform_device_id), "platform", | 966 | sizeof(struct platform_device_id), "platform", |
945 | do_platform_entry, mod); | 967 | do_platform_entry, mod); |
968 | else if (sym_is(symname, "__mod_mdio_device_table")) | ||
969 | do_table(symval, sym->st_size, | ||
970 | sizeof(struct mdio_device_id), "mdio", | ||
971 | do_mdio_entry, mod); | ||
946 | free(zeros); | 972 | free(zeros); |
947 | } | 973 | } |
948 | 974 | ||