1 #include <linux/delay.h>
2 #include <linux/gpio.h>
4 #include <linux/interrupt.h>
5 #include <linux/jiffies.h>
6 #include <linux/module.h>
7 #include <linux/mutex.h>
10 #include <linux/platform_device.h>
11 #include <linux/rtnetlink.h>
12 #include <linux/slab.h>
13 #include <linux/workqueue.h>
27 SFP_F_PRESENT = BIT(GPIO_MODDEF0),
28 SFP_F_LOS = BIT(GPIO_LOS),
29 SFP_F_TX_FAULT = BIT(GPIO_TX_FAULT),
30 SFP_F_TX_DISABLE = BIT(GPIO_TX_DISABLE),
31 SFP_F_RATE_SELECT = BIT(GPIO_RATE_SELECT),
60 static const char *gpio_of_names[] = {
68 static const enum gpiod_flags gpio_flags[] = {
76 #define T_INIT_JIFFIES msecs_to_jiffies(300)
78 #define T_FAULT_RECOVER msecs_to_jiffies(1000)
80 /* SFP module presence detection is poor: the three MOD DEF signals are
81 * the same length on the PCB, which means it's possible for MOD DEF 0 to
82 * connect before the I2C bus on MOD DEF 1/2.
84 * The SFP MSA specifies 300ms as t_init (the time taken for TX_FAULT to
85 * be deasserted) but makes no mention of the earliest time before we can
86 * access the I2C EEPROM. However, Avago modules require 300ms.
88 #define T_PROBE_INIT msecs_to_jiffies(300)
89 #define T_PROBE_RETRY msecs_to_jiffies(100)
92 * SFP modules appear to always have their PHY configured for bus address
93 * 0x56 (which with mdio-i2c, translates to a PHY address of 22).
95 #define SFP_PHY_ADDR 22
98 * Give this long for the PHY to reset.
100 #define T_PHY_RESET_MS 50
102 static DEFINE_MUTEX(sfp_mutex);
106 struct i2c_adapter *i2c;
107 struct mii_bus *i2c_mii;
108 struct sfp_bus *sfp_bus;
109 struct phy_device *mod_phy;
111 unsigned int (*get_state)(struct sfp *);
112 void (*set_state)(struct sfp *, unsigned int);
113 int (*read)(struct sfp *, bool, u8, void *, size_t);
115 struct gpio_desc *gpio[GPIO_MAX];
118 struct mutex st_mutex; /* Protects state */
120 struct delayed_work poll;
121 struct delayed_work timeout;
122 struct mutex sm_mutex; /* Protects state machine */
123 unsigned char sm_mod_state;
124 unsigned char sm_dev_state;
125 unsigned short sm_state;
126 unsigned int sm_retries;
128 struct sfp_eeprom_id id;
131 static unsigned long poll_jiffies;
133 static unsigned int sfp_gpio_get_state(struct sfp *sfp)
135 unsigned int i, state, v;
137 for (i = state = 0; i < GPIO_MAX; i++) {
138 if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i])
141 v = gpiod_get_value_cansleep(sfp->gpio[i]);
149 static void sfp_gpio_set_state(struct sfp *sfp, unsigned int state)
151 if (state & SFP_F_PRESENT) {
152 /* If the module is present, drive the signals */
153 if (sfp->gpio[GPIO_TX_DISABLE])
154 gpiod_direction_output(sfp->gpio[GPIO_TX_DISABLE],
155 state & SFP_F_TX_DISABLE);
156 if (state & SFP_F_RATE_SELECT)
157 gpiod_direction_output(sfp->gpio[GPIO_RATE_SELECT],
158 state & SFP_F_RATE_SELECT);
160 /* Otherwise, let them float to the pull-ups */
161 if (sfp->gpio[GPIO_TX_DISABLE])
162 gpiod_direction_input(sfp->gpio[GPIO_TX_DISABLE]);
163 if (state & SFP_F_RATE_SELECT)
164 gpiod_direction_input(sfp->gpio[GPIO_RATE_SELECT]);
168 static int sfp__i2c_read(struct i2c_adapter *i2c, u8 bus_addr, u8 dev_addr,
169 void *buf, size_t len)
171 struct i2c_msg msgs[2];
175 msgs[0].addr = bus_addr;
178 msgs[0].buf = &dev_addr;
179 msgs[1].addr = bus_addr;
180 msgs[1].flags = I2C_M_RD;
189 msgs[1].len = this_len;
191 ret = i2c_transfer(i2c, msgs, ARRAY_SIZE(msgs));
195 if (ret != ARRAY_SIZE(msgs))
198 msgs[1].buf += this_len;
199 dev_addr += this_len;
203 return msgs[1].buf - (u8 *)buf;
206 static int sfp_i2c_read(struct sfp *sfp, bool a2, u8 addr, void *buf,
209 return sfp__i2c_read(sfp->i2c, a2 ? 0x51 : 0x50, addr, buf, len);
212 static int sfp_i2c_configure(struct sfp *sfp, struct i2c_adapter *i2c)
214 struct mii_bus *i2c_mii;
217 if (!i2c_check_functionality(i2c, I2C_FUNC_I2C))
221 sfp->read = sfp_i2c_read;
223 i2c_mii = mdio_i2c_alloc(sfp->dev, i2c);
225 return PTR_ERR(i2c_mii);
227 i2c_mii->name = "SFP I2C Bus";
228 i2c_mii->phy_mask = ~0;
230 ret = mdiobus_register(i2c_mii);
232 mdiobus_free(i2c_mii);
236 sfp->i2c_mii = i2c_mii;
243 static unsigned int sfp_get_state(struct sfp *sfp)
245 return sfp->get_state(sfp);
248 static void sfp_set_state(struct sfp *sfp, unsigned int state)
250 sfp->set_state(sfp, state);
253 static int sfp_read(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len)
255 return sfp->read(sfp, a2, addr, buf, len);
258 static unsigned int sfp_check(void *buf, size_t len)
262 for (p = buf, check = 0; len; p++, len--)
269 static void sfp_module_tx_disable(struct sfp *sfp)
271 dev_dbg(sfp->dev, "tx disable %u -> %u\n",
272 sfp->state & SFP_F_TX_DISABLE ? 1 : 0, 1);
273 sfp->state |= SFP_F_TX_DISABLE;
274 sfp_set_state(sfp, sfp->state);
277 static void sfp_module_tx_enable(struct sfp *sfp)
279 dev_dbg(sfp->dev, "tx disable %u -> %u\n",
280 sfp->state & SFP_F_TX_DISABLE ? 1 : 0, 0);
281 sfp->state &= ~SFP_F_TX_DISABLE;
282 sfp_set_state(sfp, sfp->state);
285 static void sfp_module_tx_fault_reset(struct sfp *sfp)
287 unsigned int state = sfp->state;
289 if (state & SFP_F_TX_DISABLE)
292 sfp_set_state(sfp, state | SFP_F_TX_DISABLE);
296 sfp_set_state(sfp, state);
299 /* SFP state machine */
300 static void sfp_sm_set_timer(struct sfp *sfp, unsigned int timeout)
303 mod_delayed_work(system_power_efficient_wq, &sfp->timeout,
306 cancel_delayed_work(&sfp->timeout);
309 static void sfp_sm_next(struct sfp *sfp, unsigned int state,
310 unsigned int timeout)
312 sfp->sm_state = state;
313 sfp_sm_set_timer(sfp, timeout);
316 static void sfp_sm_ins_next(struct sfp *sfp, unsigned int state, unsigned int timeout)
318 sfp->sm_mod_state = state;
319 sfp_sm_set_timer(sfp, timeout);
322 static void sfp_sm_phy_detach(struct sfp *sfp)
324 phy_stop(sfp->mod_phy);
325 sfp_remove_phy(sfp->sfp_bus);
326 phy_device_remove(sfp->mod_phy);
327 phy_device_free(sfp->mod_phy);
331 static void sfp_sm_probe_phy(struct sfp *sfp)
333 struct phy_device *phy;
336 msleep(T_PHY_RESET_MS);
338 phy = mdiobus_scan(sfp->i2c_mii, SFP_PHY_ADDR);
339 if (phy == ERR_PTR(-ENODEV)) {
340 dev_info(sfp->dev, "no PHY detected\n");
344 dev_err(sfp->dev, "mdiobus scan returned %ld\n", PTR_ERR(phy));
348 err = sfp_add_phy(sfp->sfp_bus, phy);
350 phy_device_remove(phy);
351 phy_device_free(phy);
352 dev_err(sfp->dev, "sfp_add_phy failed: %d\n", err);
360 static void sfp_sm_link_up(struct sfp *sfp)
362 sfp_link_up(sfp->sfp_bus);
363 sfp_sm_next(sfp, SFP_S_LINK_UP, 0);
366 static void sfp_sm_link_down(struct sfp *sfp)
368 sfp_link_down(sfp->sfp_bus);
371 static void sfp_sm_link_check_los(struct sfp *sfp)
373 unsigned int los = sfp->state & SFP_F_LOS;
375 /* FIXME: what if neither SFP_OPTIONS_LOS_INVERTED nor
376 * SFP_OPTIONS_LOS_NORMAL are set? For now, we assume
377 * the same as SFP_OPTIONS_LOS_NORMAL set.
379 if (sfp->id.ext.options & cpu_to_be16(SFP_OPTIONS_LOS_INVERTED))
383 sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0);
388 static void sfp_sm_fault(struct sfp *sfp, bool warn)
390 if (sfp->sm_retries && !--sfp->sm_retries) {
391 dev_err(sfp->dev, "module persistently indicates fault, disabling\n");
392 sfp_sm_next(sfp, SFP_S_TX_DISABLE, 0);
395 dev_err(sfp->dev, "module transmit fault indicated\n");
397 sfp_sm_next(sfp, SFP_S_TX_FAULT, T_FAULT_RECOVER);
401 static void sfp_sm_mod_init(struct sfp *sfp)
403 sfp_module_tx_enable(sfp);
405 /* Wait t_init before indicating that the link is up, provided the
406 * current state indicates no TX_FAULT. If TX_FAULT clears before
407 * this time, that's fine too.
409 sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES);
412 /* Setting the serdes link mode is guesswork: there's no
413 * field in the EEPROM which indicates what mode should
416 * If it's a gigabit-only fiber module, it probably does
417 * not have a PHY, so switch to 802.3z negotiation mode.
418 * Otherwise, switch to SGMII mode (which is required to
419 * support non-gigabit speeds) and probe for a PHY.
421 if (sfp->id.base.e1000_base_t ||
422 sfp->id.base.e100_base_lx ||
423 sfp->id.base.e100_base_fx)
424 sfp_sm_probe_phy(sfp);
427 static int sfp_sm_mod_probe(struct sfp *sfp)
429 /* SFP module inserted - read I2C data */
430 struct sfp_eeprom_id id;
439 err = sfp_read(sfp, false, 0, &id, sizeof(id));
441 dev_err(sfp->dev, "failed to read EEPROM: %d\n", err);
445 if (err != sizeof(id)) {
446 dev_err(sfp->dev, "EEPROM short read: %d\n", err);
450 /* Validate the checksum over the base structure */
451 check = sfp_check(&id.base, sizeof(id.base) - 1);
452 if (check != id.base.cc_base) {
454 "EEPROM base structure checksum failure: 0x%02x\n",
456 print_hex_dump(KERN_ERR, "sfp EE: ", DUMP_PREFIX_OFFSET,
457 16, 1, &id, sizeof(id.base) - 1, true);
461 check = sfp_check(&id.ext, sizeof(id.ext) - 1);
462 if (check != id.ext.cc_ext) {
464 "EEPROM extended structure checksum failure: 0x%02x\n",
466 memset(&id.ext, 0, sizeof(id.ext));
471 memcpy(vendor, sfp->id.base.vendor_name, 16);
473 memcpy(part, sfp->id.base.vendor_pn, 16);
475 memcpy(rev, sfp->id.base.vendor_rev, 4);
477 memcpy(sn, sfp->id.ext.vendor_sn, 16);
479 memcpy(date, sfp->id.ext.datecode, 8);
482 dev_info(sfp->dev, "module %s %s rev %s sn %s dc %s\n", vendor, part, rev, sn, date);
484 /* We only support SFP modules, not the legacy GBIC modules. */
485 if (sfp->id.base.phys_id != SFP_PHYS_ID_SFP ||
486 sfp->id.base.phys_ext_id != SFP_PHYS_EXT_ID_SFP) {
487 dev_err(sfp->dev, "module is not SFP - phys id 0x%02x 0x%02x\n",
488 sfp->id.base.phys_id, sfp->id.base.phys_ext_id);
492 return sfp_module_insert(sfp->sfp_bus, &sfp->id);
495 static void sfp_sm_mod_remove(struct sfp *sfp)
497 sfp_module_remove(sfp->sfp_bus);
500 sfp_sm_phy_detach(sfp);
502 sfp_module_tx_disable(sfp);
504 memset(&sfp->id, 0, sizeof(sfp->id));
506 dev_info(sfp->dev, "module removed\n");
509 static void sfp_sm_event(struct sfp *sfp, unsigned int event)
511 mutex_lock(&sfp->sm_mutex);
513 dev_dbg(sfp->dev, "SM: enter %u:%u:%u event %u\n",
514 sfp->sm_mod_state, sfp->sm_dev_state, sfp->sm_state, event);
516 /* This state machine tracks the insert/remove state of
517 * the module, and handles probing the on-board EEPROM.
519 switch (sfp->sm_mod_state) {
521 if (event == SFP_E_INSERT && sfp->attached) {
522 sfp_module_tx_disable(sfp);
523 sfp_sm_ins_next(sfp, SFP_MOD_PROBE, T_PROBE_INIT);
528 if (event == SFP_E_REMOVE) {
529 sfp_sm_ins_next(sfp, SFP_MOD_EMPTY, 0);
530 } else if (event == SFP_E_TIMEOUT) {
531 int err = sfp_sm_mod_probe(sfp);
534 sfp_sm_ins_next(sfp, SFP_MOD_PRESENT, 0);
535 else if (err == -EAGAIN)
536 sfp_sm_set_timer(sfp, T_PROBE_RETRY);
538 sfp_sm_ins_next(sfp, SFP_MOD_ERROR, 0);
542 case SFP_MOD_PRESENT:
544 if (event == SFP_E_REMOVE) {
545 sfp_sm_mod_remove(sfp);
546 sfp_sm_ins_next(sfp, SFP_MOD_EMPTY, 0);
551 /* This state machine tracks the netdev up/down state */
552 switch (sfp->sm_dev_state) {
554 if (event == SFP_E_DEV_UP)
555 sfp->sm_dev_state = SFP_DEV_UP;
559 if (event == SFP_E_DEV_DOWN) {
560 /* If the module has a PHY, avoid raising TX disable
561 * as this resets the PHY. Otherwise, raise it to
562 * turn the laser off.
565 sfp_module_tx_disable(sfp);
566 sfp->sm_dev_state = SFP_DEV_DOWN;
571 /* Some events are global */
572 if (sfp->sm_state != SFP_S_DOWN &&
573 (sfp->sm_mod_state != SFP_MOD_PRESENT ||
574 sfp->sm_dev_state != SFP_DEV_UP)) {
575 if (sfp->sm_state == SFP_S_LINK_UP &&
576 sfp->sm_dev_state == SFP_DEV_UP)
577 sfp_sm_link_down(sfp);
579 sfp_sm_phy_detach(sfp);
580 sfp_sm_next(sfp, SFP_S_DOWN, 0);
581 mutex_unlock(&sfp->sm_mutex);
585 /* The main state machine */
586 switch (sfp->sm_state) {
588 if (sfp->sm_mod_state == SFP_MOD_PRESENT &&
589 sfp->sm_dev_state == SFP_DEV_UP)
590 sfp_sm_mod_init(sfp);
594 if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT)
595 sfp_sm_fault(sfp, true);
596 else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR)
597 sfp_sm_link_check_los(sfp);
601 if (event == SFP_E_TX_FAULT)
602 sfp_sm_fault(sfp, true);
604 (sfp->id.ext.options &
605 cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) ?
606 SFP_E_LOS_HIGH : SFP_E_LOS_LOW))
611 if (event == SFP_E_TX_FAULT) {
612 sfp_sm_link_down(sfp);
613 sfp_sm_fault(sfp, true);
615 (sfp->id.ext.options &
616 cpu_to_be16(SFP_OPTIONS_LOS_INVERTED) ?
617 SFP_E_LOS_LOW : SFP_E_LOS_HIGH)) {
618 sfp_sm_link_down(sfp);
619 sfp_sm_next(sfp, SFP_S_WAIT_LOS, 0);
624 if (event == SFP_E_TIMEOUT) {
625 sfp_module_tx_fault_reset(sfp);
626 sfp_sm_next(sfp, SFP_S_REINIT, T_INIT_JIFFIES);
631 if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) {
632 sfp_sm_fault(sfp, false);
633 } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
634 dev_info(sfp->dev, "module transmit fault recovered\n");
635 sfp_sm_link_check_los(sfp);
639 case SFP_S_TX_DISABLE:
643 dev_dbg(sfp->dev, "SM: exit %u:%u:%u\n",
644 sfp->sm_mod_state, sfp->sm_dev_state, sfp->sm_state);
646 mutex_unlock(&sfp->sm_mutex);
649 static void sfp_attach(struct sfp *sfp)
651 sfp->attached = true;
652 if (sfp->state & SFP_F_PRESENT)
653 sfp_sm_event(sfp, SFP_E_INSERT);
656 static void sfp_detach(struct sfp *sfp)
658 sfp->attached = false;
659 sfp_sm_event(sfp, SFP_E_REMOVE);
662 static void sfp_start(struct sfp *sfp)
664 sfp_sm_event(sfp, SFP_E_DEV_UP);
667 static void sfp_stop(struct sfp *sfp)
669 sfp_sm_event(sfp, SFP_E_DEV_DOWN);
672 static int sfp_module_info(struct sfp *sfp, struct ethtool_modinfo *modinfo)
674 /* locking... and check module is present */
676 if (sfp->id.ext.sff8472_compliance) {
677 modinfo->type = ETH_MODULE_SFF_8472;
678 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
680 modinfo->type = ETH_MODULE_SFF_8079;
681 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
686 static int sfp_module_eeprom(struct sfp *sfp, struct ethtool_eeprom *ee,
689 unsigned int first, last, len;
696 last = ee->offset + ee->len;
697 if (first < ETH_MODULE_SFF_8079_LEN) {
698 len = min_t(unsigned int, last, ETH_MODULE_SFF_8079_LEN);
701 ret = sfp_read(sfp, false, first, data, len);
708 if (first < ETH_MODULE_SFF_8472_LEN && last > ETH_MODULE_SFF_8079_LEN) {
709 len = min_t(unsigned int, last, ETH_MODULE_SFF_8472_LEN);
711 first -= ETH_MODULE_SFF_8079_LEN;
713 ret = sfp_read(sfp, true, first, data, len);
720 static const struct sfp_socket_ops sfp_module_ops = {
721 .attach = sfp_attach,
722 .detach = sfp_detach,
725 .module_info = sfp_module_info,
726 .module_eeprom = sfp_module_eeprom,
729 static void sfp_timeout(struct work_struct *work)
731 struct sfp *sfp = container_of(work, struct sfp, timeout.work);
734 sfp_sm_event(sfp, SFP_E_TIMEOUT);
738 static void sfp_check_state(struct sfp *sfp)
740 unsigned int state, i, changed;
742 mutex_lock(&sfp->st_mutex);
743 state = sfp_get_state(sfp);
744 changed = state ^ sfp->state;
745 changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
747 for (i = 0; i < GPIO_MAX; i++)
748 if (changed & BIT(i))
749 dev_dbg(sfp->dev, "%s %u -> %u\n", gpio_of_names[i],
750 !!(sfp->state & BIT(i)), !!(state & BIT(i)));
752 state |= sfp->state & (SFP_F_TX_DISABLE | SFP_F_RATE_SELECT);
756 if (changed & SFP_F_PRESENT)
757 sfp_sm_event(sfp, state & SFP_F_PRESENT ?
758 SFP_E_INSERT : SFP_E_REMOVE);
760 if (changed & SFP_F_TX_FAULT)
761 sfp_sm_event(sfp, state & SFP_F_TX_FAULT ?
762 SFP_E_TX_FAULT : SFP_E_TX_CLEAR);
764 if (changed & SFP_F_LOS)
765 sfp_sm_event(sfp, state & SFP_F_LOS ?
766 SFP_E_LOS_HIGH : SFP_E_LOS_LOW);
768 mutex_unlock(&sfp->st_mutex);
771 static irqreturn_t sfp_irq(int irq, void *data)
773 struct sfp *sfp = data;
775 sfp_check_state(sfp);
780 static void sfp_poll(struct work_struct *work)
782 struct sfp *sfp = container_of(work, struct sfp, poll.work);
784 sfp_check_state(sfp);
785 mod_delayed_work(system_wq, &sfp->poll, poll_jiffies);
788 static struct sfp *sfp_alloc(struct device *dev)
792 sfp = kzalloc(sizeof(*sfp), GFP_KERNEL);
794 return ERR_PTR(-ENOMEM);
798 mutex_init(&sfp->sm_mutex);
799 mutex_init(&sfp->st_mutex);
800 INIT_DELAYED_WORK(&sfp->poll, sfp_poll);
801 INIT_DELAYED_WORK(&sfp->timeout, sfp_timeout);
806 static void sfp_cleanup(void *data)
808 struct sfp *sfp = data;
810 cancel_delayed_work_sync(&sfp->poll);
811 cancel_delayed_work_sync(&sfp->timeout);
813 mdiobus_unregister(sfp->i2c_mii);
814 mdiobus_free(sfp->i2c_mii);
817 i2c_put_adapter(sfp->i2c);
821 static int sfp_probe(struct platform_device *pdev)
827 sfp = sfp_alloc(&pdev->dev);
831 platform_set_drvdata(pdev, sfp);
833 err = devm_add_action(sfp->dev, sfp_cleanup, sfp);
837 if (pdev->dev.of_node) {
838 struct device_node *node = pdev->dev.of_node;
839 struct device_node *np;
841 np = of_parse_phandle(node, "i2c-bus", 0);
843 struct i2c_adapter *i2c;
845 i2c = of_find_i2c_adapter_by_node(np);
848 return -EPROBE_DEFER;
850 err = sfp_i2c_configure(sfp, i2c);
852 i2c_put_adapter(i2c);
857 for (i = 0; i < GPIO_MAX; i++) {
858 sfp->gpio[i] = devm_gpiod_get_optional(sfp->dev,
859 gpio_of_names[i], gpio_flags[i]);
860 if (IS_ERR(sfp->gpio[i]))
861 return PTR_ERR(sfp->gpio[i]);
864 sfp->get_state = sfp_gpio_get_state;
865 sfp->set_state = sfp_gpio_set_state;
868 /* Get the initial state, and always signal TX disable,
869 * since the network interface will not be up.
871 sfp->state = sfp_get_state(sfp) | SFP_F_TX_DISABLE;
873 if (sfp->gpio[GPIO_RATE_SELECT] &&
874 gpiod_get_value_cansleep(sfp->gpio[GPIO_RATE_SELECT]))
875 sfp->state |= SFP_F_RATE_SELECT;
876 sfp_set_state(sfp, sfp->state);
877 sfp_module_tx_disable(sfp);
879 for (i = 0; i < GPIO_MAX; i++) {
880 if (gpio_flags[i] != GPIOD_IN || !sfp->gpio[i])
883 irq = gpiod_to_irq(sfp->gpio[i]);
890 err = devm_request_threaded_irq(sfp->dev, irq, NULL, sfp_irq,
892 IRQF_TRIGGER_RISING |
893 IRQF_TRIGGER_FALLING,
894 dev_name(sfp->dev), sfp);
900 mod_delayed_work(system_wq, &sfp->poll, poll_jiffies);
902 sfp->sfp_bus = sfp_register_socket(sfp->dev, sfp, &sfp_module_ops);
909 static int sfp_remove(struct platform_device *pdev)
911 struct sfp *sfp = platform_get_drvdata(pdev);
913 sfp_unregister_socket(sfp->sfp_bus);
918 static const struct of_device_id sfp_of_match[] = {
919 { .compatible = "sff,sfp", },
922 MODULE_DEVICE_TABLE(of, sfp_of_match);
924 static struct platform_driver sfp_driver = {
926 .remove = sfp_remove,
929 .of_match_table = sfp_of_match,
933 static int sfp_init(void)
935 poll_jiffies = msecs_to_jiffies(100);
937 return platform_driver_register(&sfp_driver);
939 module_init(sfp_init);
941 static void sfp_exit(void)
943 platform_driver_unregister(&sfp_driver);
945 module_exit(sfp_exit);
947 MODULE_ALIAS("platform:sfp");
948 MODULE_AUTHOR("Russell King");
949 MODULE_LICENSE("GPL v2");