Lines Matching +full:chip +full:- +full:select

5  * Dante Su <dantesu@faraday-tech.com>
7 * SPDX-License-Identifier: GPL-2.0+
10 * Please see doc/driver-model/i2c-howto.txt for instructions.
35 /* 7-bit dev address + 1-bit read/write */
64 static int fti2c010_reset(struct fti2c010_chip *chip) in fti2c010_reset() argument
67 int ret = -1; in fti2c010_reset()
68 struct fti2c010_regs *regs = chip->regs; in fti2c010_reset()
70 writel(CR_I2CRST, &regs->cr); in fti2c010_reset()
72 if (!(readl(&regs->cr) & CR_I2CRST)) { in fti2c010_reset()
84 static int fti2c010_wait(struct fti2c010_chip *chip, uint32_t mask) in fti2c010_wait() argument
86 int ret = -1; in fti2c010_wait()
88 struct fti2c010_regs *regs = chip->regs; in fti2c010_wait()
91 stat = readl(&regs->sr); in fti2c010_wait()
101 static unsigned int set_i2c_bus_speed(struct fti2c010_chip *chip, in set_i2c_bus_speed() argument
104 struct fti2c010_regs *regs = chip->regs; in set_i2c_bus_speed()
117 writel(TGSR_GSR(gsr) | TGSR_TSR(tsr), &regs->tgsr); in set_i2c_bus_speed()
118 writel(CDR_DIV(div), &regs->cdr); in set_i2c_bus_speed()
129 struct fti2c010_chip *chip = chip_list + adap->hwadapnr; in fti2c010_init() local
131 if (adap->init_done) in fti2c010_init()
136 * environment, which might be in a chip on that bus. For details in fti2c010_init()
144 fti2c010_reset(chip); in fti2c010_init()
146 set_i2c_bus_speed(chip, speed); in fti2c010_init()
152 * Probe the given I2C chip address. Returns 0 if a chip responded,
157 struct fti2c010_chip *chip = chip_list + adap->hwadapnr; in fti2c010_probe() local
158 struct fti2c010_regs *regs = chip->regs; in fti2c010_probe()
161 /* 1. Select slave device (7bits Address + 1bit R/W) */ in fti2c010_probe()
162 writel(I2C_WR(dev), &regs->dr); in fti2c010_probe()
163 writel(CR_ENABLE | CR_TBEN | CR_START, &regs->cr); in fti2c010_probe()
164 ret = fti2c010_wait(chip, SR_DT); in fti2c010_probe()
168 /* 2. Select device register */ in fti2c010_probe()
169 writel(0, &regs->dr); in fti2c010_probe()
170 writel(CR_ENABLE | CR_TBEN, &regs->cr); in fti2c010_probe()
171 ret = fti2c010_wait(chip, SR_DT); in fti2c010_probe()
185 shift = (alen - 1) * 8; in to_i2c_addr()
186 while (alen-- > 0) { in to_i2c_addr()
188 shift -= 8; in to_i2c_addr()
195 struct fti2c010_chip *chip = chip_list + adap->hwadapnr; in fti2c010_read() local
196 struct fti2c010_regs *regs = chip->regs; in fti2c010_read()
206 /* A.1 Select slave device (7bits Address + 1bit R/W) */ in fti2c010_read()
207 writel(I2C_WR(dev), &regs->dr); in fti2c010_read()
208 writel(CR_ENABLE | CR_TBEN | CR_START, &regs->cr); in fti2c010_read()
209 ret = fti2c010_wait(chip, SR_DT); in fti2c010_read()
213 /* A.2 Select device register */ in fti2c010_read()
217 writel(paddr[pos], &regs->dr); in fti2c010_read()
218 writel(ctrl, &regs->cr); in fti2c010_read()
219 ret = fti2c010_wait(chip, SR_DT); in fti2c010_read()
228 /* B.1 Select slave device (7bits Address + 1bit R/W) */ in fti2c010_read()
229 writel(I2C_RD(dev), &regs->dr); in fti2c010_read()
230 writel(CR_ENABLE | CR_TBEN | CR_START, &regs->cr); in fti2c010_read()
231 ret = fti2c010_wait(chip, SR_DT); in fti2c010_read()
240 if (pos == len - 1) { in fti2c010_read()
244 writel(ctrl, &regs->cr); in fti2c010_read()
245 ret = fti2c010_wait(chip, stat); in fti2c010_read()
248 buf[pos] = (uchar)(readl(&regs->dr) & 0xFF); in fti2c010_read()
257 struct fti2c010_chip *chip = chip_list + adap->hwadapnr; in fti2c010_write() local
258 struct fti2c010_regs *regs = chip->regs; in fti2c010_write()
267 * A.1 Select slave device (7bits Address + 1bit R/W) in fti2c010_write()
269 writel(I2C_WR(dev), &regs->dr); in fti2c010_write()
270 writel(CR_ENABLE | CR_TBEN | CR_START, &regs->cr); in fti2c010_write()
271 ret = fti2c010_wait(chip, SR_DT); in fti2c010_write()
275 /* A.2 Select device register */ in fti2c010_write()
279 writel(paddr[pos], &regs->dr); in fti2c010_write()
280 writel(ctrl, &regs->cr); in fti2c010_write()
281 ret = fti2c010_wait(chip, SR_DT); in fti2c010_write()
292 if (pos == len - 1) in fti2c010_write()
294 writel(buf[pos], &regs->dr); in fti2c010_write()
295 writel(ctrl, &regs->cr); in fti2c010_write()
296 ret = fti2c010_wait(chip, SR_DT); in fti2c010_write()
307 struct fti2c010_chip *chip = chip_list + adap->hwadapnr; in fti2c010_set_bus_speed() local
310 fti2c010_reset(chip); in fti2c010_set_bus_speed()
311 ret = set_i2c_bus_speed(chip, speed); in fti2c010_set_bus_speed()