diff options
author | Giuseppe Cavallaro <peppe.cavallaro@st.com> | 2008-11-28 19:42:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-28 19:42:41 -0500 |
commit | f95be1806fde884c1655237d49a7e5f82e4a935f (patch) | |
tree | 546cf0d1ea682fa6580b1cf387ed8c78fed9a5ec /drivers/net/phy | |
parent | 4621bf129856bad902d7662053b79faaeb3e66cc (diff) |
phy: add the ST ste10Xp PHYs
This patch adds the STMicroelectronics ste10xp PHY device driver.
It supports both the ste100p and the ste101p devices.
Suspend/resume alredy added.
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/Kconfig | 6 | ||||
-rw-r--r-- | drivers/net/phy/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/phy/ste10Xp.c | 137 |
3 files changed, 144 insertions, 0 deletions
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index a1938e18cb62..0b368dc49aea 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
@@ -71,6 +71,12 @@ config NATIONAL_PHY | |||
71 | ---help--- | 71 | ---help--- |
72 | Currently supports the DP83865 PHY. | 72 | Currently supports the DP83865 PHY. |
73 | 73 | ||
74 | config STE10XP | ||
75 | depends on PHYLIB | ||
76 | tristate "Driver for STMicroelectronics STe10Xp PHYs" | ||
77 | ---help--- | ||
78 | This is the driver for the STe100p and STe101p PHYs. | ||
79 | |||
74 | config FIXED_PHY | 80 | config FIXED_PHY |
75 | bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs" | 81 | bool "Driver for MDIO Bus/PHY emulation with fixed speed/link PHYs" |
76 | depends on PHYLIB=y | 82 | depends on PHYLIB=y |
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index eba495453aef..67959c9d4ca5 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile | |||
@@ -17,3 +17,4 @@ obj-$(CONFIG_FIXED_PHY) += fixed.o | |||
17 | obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o | 17 | obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o |
18 | obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o | 18 | obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o |
19 | obj-$(CONFIG_NATIONAL_PHY) += national.o | 19 | obj-$(CONFIG_NATIONAL_PHY) += national.o |
20 | obj-$(CONFIG_STE10XP) += ste10Xp.o | ||
diff --git a/drivers/net/phy/ste10Xp.c b/drivers/net/phy/ste10Xp.c new file mode 100644 index 000000000000..6bdb0d53aaf9 --- /dev/null +++ b/drivers/net/phy/ste10Xp.c | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | * drivers/net/phy/ste10Xp.c | ||
3 | * | ||
4 | * Driver for STMicroelectronics STe10Xp PHYs | ||
5 | * | ||
6 | * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> | ||
7 | * | ||
8 | * Copyright (c) 2008 STMicroelectronics Limited | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License as published by the | ||
12 | * Free Software Foundation; either version 2 of the License, or (at your | ||
13 | * option) any later version. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include <linux/module.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/sched.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/netdevice.h> | ||
24 | #include <linux/ethtool.h> | ||
25 | #include <linux/mii.h> | ||
26 | #include <linux/phy.h> | ||
27 | |||
28 | #define MII_XCIIS 0x11 /* Configuration Info IRQ & Status Reg */ | ||
29 | #define MII_XIE 0x12 /* Interrupt Enable Register */ | ||
30 | #define MII_XIE_DEFAULT_MASK 0x0070 /* ANE complete, Remote Fault, Link Down */ | ||
31 | |||
32 | #define STE101P_PHY_ID 0x00061c50 | ||
33 | #define STE100P_PHY_ID 0x1c040011 | ||
34 | |||
35 | static int ste10Xp_config_init(struct phy_device *phydev) | ||
36 | { | ||
37 | int value, err; | ||
38 | |||
39 | /* Software Reset PHY */ | ||
40 | value = phy_read(phydev, MII_BMCR); | ||
41 | if (value < 0) | ||
42 | return value; | ||
43 | |||
44 | value |= BMCR_RESET; | ||
45 | err = phy_write(phydev, MII_BMCR, value); | ||
46 | if (err < 0) | ||
47 | return err; | ||
48 | |||
49 | do { | ||
50 | value = phy_read(phydev, MII_BMCR); | ||
51 | } while (value & BMCR_RESET); | ||
52 | |||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | static int ste10Xp_config_intr(struct phy_device *phydev) | ||
57 | { | ||
58 | int err, value; | ||
59 | |||
60 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { | ||
61 | /* Enable all STe101P interrupts (PR12) */ | ||
62 | err = phy_write(phydev, MII_XIE, MII_XIE_DEFAULT_MASK); | ||
63 | /* clear any pending interrupts */ | ||
64 | if (err == 0) { | ||
65 | value = phy_read(phydev, MII_XCIIS); | ||
66 | if (value < 0) | ||
67 | err = value; | ||
68 | } | ||
69 | } else | ||
70 | err = phy_write(phydev, MII_XIE, 0); | ||
71 | |||
72 | return err; | ||
73 | } | ||
74 | |||
75 | static int ste10Xp_ack_interrupt(struct phy_device *phydev) | ||
76 | { | ||
77 | int err = phy_read(phydev, MII_XCIIS); | ||
78 | if (err < 0) | ||
79 | return err; | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static struct phy_driver ste101p_pdriver = { | ||
85 | .phy_id = STE101P_PHY_ID, | ||
86 | .phy_id_mask = 0xfffffff0, | ||
87 | .name = "STe101p", | ||
88 | .features = PHY_BASIC_FEATURES | SUPPORTED_Pause, | ||
89 | .flags = PHY_HAS_INTERRUPT, | ||
90 | .config_init = ste10Xp_config_init, | ||
91 | .config_aneg = genphy_config_aneg, | ||
92 | .read_status = genphy_read_status, | ||
93 | .ack_interrupt = ste10Xp_ack_interrupt, | ||
94 | .config_intr = ste10Xp_config_intr, | ||
95 | .suspend = genphy_suspend, | ||
96 | .resume = genphy_resume, | ||
97 | .driver = {.owner = THIS_MODULE,} | ||
98 | }; | ||
99 | |||
100 | static struct phy_driver ste100p_pdriver = { | ||
101 | .phy_id = STE100P_PHY_ID, | ||
102 | .phy_id_mask = 0xffffffff, | ||
103 | .name = "STe100p", | ||
104 | .features = PHY_BASIC_FEATURES | SUPPORTED_Pause, | ||
105 | .flags = PHY_HAS_INTERRUPT, | ||
106 | .config_init = ste10Xp_config_init, | ||
107 | .config_aneg = genphy_config_aneg, | ||
108 | .read_status = genphy_read_status, | ||
109 | .ack_interrupt = ste10Xp_ack_interrupt, | ||
110 | .config_intr = ste10Xp_config_intr, | ||
111 | .suspend = genphy_suspend, | ||
112 | .resume = genphy_resume, | ||
113 | .driver = {.owner = THIS_MODULE,} | ||
114 | }; | ||
115 | |||
116 | static int __init ste10Xp_init(void) | ||
117 | { | ||
118 | int retval; | ||
119 | |||
120 | retval = phy_driver_register(&ste100p_pdriver); | ||
121 | if (retval < 0) | ||
122 | return retval; | ||
123 | return phy_driver_register(&ste101p_pdriver); | ||
124 | } | ||
125 | |||
126 | static void __exit ste10Xp_exit(void) | ||
127 | { | ||
128 | phy_driver_unregister(&ste100p_pdriver); | ||
129 | phy_driver_unregister(&ste101p_pdriver); | ||
130 | } | ||
131 | |||
132 | module_init(ste10Xp_init); | ||
133 | module_exit(ste10Xp_exit); | ||
134 | |||
135 | MODULE_DESCRIPTION("STMicroelectronics STe10Xp PHY driver"); | ||
136 | MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); | ||
137 | MODULE_LICENSE("GPL"); | ||