Lines Matching full:chip
13 #include "chip.h"
16 int mv88e6165_phy_read(struct mv88e6xxx_chip *chip, struct mii_bus *bus, in mv88e6165_phy_read() argument
19 return mv88e6xxx_read(chip, addr, reg, val); in mv88e6165_phy_read()
22 int mv88e6165_phy_write(struct mv88e6xxx_chip *chip, struct mii_bus *bus, in mv88e6165_phy_write() argument
25 return mv88e6xxx_write(chip, addr, reg, val); in mv88e6165_phy_write()
28 int mv88e6xxx_phy_read(struct mv88e6xxx_chip *chip, int phy, int reg, u16 *val) in mv88e6xxx_phy_read() argument
33 bus = mv88e6xxx_default_mdio_bus(chip); in mv88e6xxx_phy_read()
37 if (!chip->info->ops->phy_read) in mv88e6xxx_phy_read()
40 return chip->info->ops->phy_read(chip, bus, addr, reg, val); in mv88e6xxx_phy_read()
43 int mv88e6xxx_phy_write(struct mv88e6xxx_chip *chip, int phy, int reg, u16 val) in mv88e6xxx_phy_write() argument
48 bus = mv88e6xxx_default_mdio_bus(chip); in mv88e6xxx_phy_write()
52 if (!chip->info->ops->phy_write) in mv88e6xxx_phy_write()
55 return chip->info->ops->phy_write(chip, bus, addr, reg, val); in mv88e6xxx_phy_write()
58 static int mv88e6xxx_phy_page_get(struct mv88e6xxx_chip *chip, int phy, u8 page) in mv88e6xxx_phy_page_get() argument
60 return mv88e6xxx_phy_write(chip, phy, MV88E6XXX_PHY_PAGE, page); in mv88e6xxx_phy_page_get()
63 static void mv88e6xxx_phy_page_put(struct mv88e6xxx_chip *chip, int phy) in mv88e6xxx_phy_page_put() argument
70 err = mv88e6xxx_phy_write(chip, phy, MV88E6XXX_PHY_PAGE, in mv88e6xxx_phy_page_put()
73 dev_err(chip->dev, in mv88e6xxx_phy_page_put()
79 int mv88e6xxx_phy_page_read(struct mv88e6xxx_chip *chip, int phy, in mv88e6xxx_phy_page_read() argument
88 err = mv88e6xxx_phy_page_get(chip, phy, page); in mv88e6xxx_phy_page_read()
90 err = mv88e6xxx_phy_read(chip, phy, reg, val); in mv88e6xxx_phy_page_read()
91 mv88e6xxx_phy_page_put(chip, phy); in mv88e6xxx_phy_page_read()
97 int mv88e6xxx_phy_page_write(struct mv88e6xxx_chip *chip, int phy, in mv88e6xxx_phy_page_write() argument
106 err = mv88e6xxx_phy_page_get(chip, phy, page); in mv88e6xxx_phy_page_write()
108 err = mv88e6xxx_phy_write(chip, phy, MV88E6XXX_PHY_PAGE, page); in mv88e6xxx_phy_page_write()
110 err = mv88e6xxx_phy_write(chip, phy, reg, val); in mv88e6xxx_phy_page_write()
112 mv88e6xxx_phy_page_put(chip, phy); in mv88e6xxx_phy_page_write()
118 static int mv88e6xxx_phy_ppu_disable(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_ppu_disable() argument
120 if (!chip->info->ops->ppu_disable) in mv88e6xxx_phy_ppu_disable()
123 return chip->info->ops->ppu_disable(chip); in mv88e6xxx_phy_ppu_disable()
126 static int mv88e6xxx_phy_ppu_enable(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_ppu_enable() argument
128 if (!chip->info->ops->ppu_enable) in mv88e6xxx_phy_ppu_enable()
131 return chip->info->ops->ppu_enable(chip); in mv88e6xxx_phy_ppu_enable()
136 struct mv88e6xxx_chip *chip; in mv88e6xxx_phy_ppu_reenable_work() local
138 chip = container_of(ugly, struct mv88e6xxx_chip, ppu_work); in mv88e6xxx_phy_ppu_reenable_work()
140 mv88e6xxx_reg_lock(chip); in mv88e6xxx_phy_ppu_reenable_work()
142 if (mutex_trylock(&chip->ppu_mutex)) { in mv88e6xxx_phy_ppu_reenable_work()
143 if (mv88e6xxx_phy_ppu_enable(chip) == 0) in mv88e6xxx_phy_ppu_reenable_work()
144 chip->ppu_disabled = 0; in mv88e6xxx_phy_ppu_reenable_work()
145 mutex_unlock(&chip->ppu_mutex); in mv88e6xxx_phy_ppu_reenable_work()
148 mv88e6xxx_reg_unlock(chip); in mv88e6xxx_phy_ppu_reenable_work()
153 struct mv88e6xxx_chip *chip = from_timer(chip, t, ppu_timer); in mv88e6xxx_phy_ppu_reenable_timer() local
155 schedule_work(&chip->ppu_work); in mv88e6xxx_phy_ppu_reenable_timer()
158 static int mv88e6xxx_phy_ppu_access_get(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_ppu_access_get() argument
162 mutex_lock(&chip->ppu_mutex); in mv88e6xxx_phy_ppu_access_get()
169 if (!chip->ppu_disabled) { in mv88e6xxx_phy_ppu_access_get()
170 ret = mv88e6xxx_phy_ppu_disable(chip); in mv88e6xxx_phy_ppu_access_get()
172 mutex_unlock(&chip->ppu_mutex); in mv88e6xxx_phy_ppu_access_get()
175 chip->ppu_disabled = 1; in mv88e6xxx_phy_ppu_access_get()
177 del_timer(&chip->ppu_timer); in mv88e6xxx_phy_ppu_access_get()
184 static void mv88e6xxx_phy_ppu_access_put(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_ppu_access_put() argument
187 mod_timer(&chip->ppu_timer, jiffies + msecs_to_jiffies(10)); in mv88e6xxx_phy_ppu_access_put()
188 mutex_unlock(&chip->ppu_mutex); in mv88e6xxx_phy_ppu_access_put()
191 static void mv88e6xxx_phy_ppu_state_init(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_ppu_state_init() argument
193 mutex_init(&chip->ppu_mutex); in mv88e6xxx_phy_ppu_state_init()
194 INIT_WORK(&chip->ppu_work, mv88e6xxx_phy_ppu_reenable_work); in mv88e6xxx_phy_ppu_state_init()
195 timer_setup(&chip->ppu_timer, mv88e6xxx_phy_ppu_reenable_timer, 0); in mv88e6xxx_phy_ppu_state_init()
198 static void mv88e6xxx_phy_ppu_state_destroy(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_ppu_state_destroy() argument
200 del_timer_sync(&chip->ppu_timer); in mv88e6xxx_phy_ppu_state_destroy()
203 int mv88e6185_phy_ppu_read(struct mv88e6xxx_chip *chip, struct mii_bus *bus, in mv88e6185_phy_ppu_read() argument
208 err = mv88e6xxx_phy_ppu_access_get(chip); in mv88e6185_phy_ppu_read()
210 err = mv88e6xxx_read(chip, addr, reg, val); in mv88e6185_phy_ppu_read()
211 mv88e6xxx_phy_ppu_access_put(chip); in mv88e6185_phy_ppu_read()
217 int mv88e6185_phy_ppu_write(struct mv88e6xxx_chip *chip, struct mii_bus *bus, in mv88e6185_phy_ppu_write() argument
222 err = mv88e6xxx_phy_ppu_access_get(chip); in mv88e6185_phy_ppu_write()
224 err = mv88e6xxx_write(chip, addr, reg, val); in mv88e6185_phy_ppu_write()
225 mv88e6xxx_phy_ppu_access_put(chip); in mv88e6185_phy_ppu_write()
231 void mv88e6xxx_phy_init(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_init() argument
233 if (chip->info->ops->ppu_enable && chip->info->ops->ppu_disable) in mv88e6xxx_phy_init()
234 mv88e6xxx_phy_ppu_state_init(chip); in mv88e6xxx_phy_init()
237 void mv88e6xxx_phy_destroy(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_destroy() argument
239 if (chip->info->ops->ppu_enable && chip->info->ops->ppu_disable) in mv88e6xxx_phy_destroy()
240 mv88e6xxx_phy_ppu_state_destroy(chip); in mv88e6xxx_phy_destroy()
243 int mv88e6xxx_phy_setup(struct mv88e6xxx_chip *chip) in mv88e6xxx_phy_setup() argument
245 return mv88e6xxx_phy_ppu_enable(chip); in mv88e6xxx_phy_setup()