Lines Matching refs:bp

54 static void set_device_claimage(struct bbc_i2c_bus *bp, struct platform_device *op, int val)  in set_device_claimage()  argument
59 if (bp->devs[i].device == op) { in set_device_claimage()
60 bp->devs[i].client_claimed = val; in set_device_claimage()
69 struct platform_device *bbc_i2c_getdev(struct bbc_i2c_bus *bp, int index) in bbc_i2c_getdev() argument
75 if (!(op = bp->devs[i].device)) in bbc_i2c_getdev()
89 struct bbc_i2c_client *bbc_i2c_attach(struct bbc_i2c_bus *bp, struct platform_device *op) in bbc_i2c_attach() argument
97 client->bp = bp; in bbc_i2c_attach()
109 claim_device(bp, op); in bbc_i2c_attach()
116 struct bbc_i2c_bus *bp = client->bp; in bbc_i2c_detach() local
119 release_device(bp, op); in bbc_i2c_detach()
123 static int wait_for_pin(struct bbc_i2c_bus *bp, u8 *status) in wait_for_pin() argument
129 bp->waiting = 1; in wait_for_pin()
130 add_wait_queue(&bp->wq, &wait); in wait_for_pin()
135 bp->wq, in wait_for_pin()
136 (((*status = readb(bp->i2c_control_regs + 0)) in wait_for_pin()
144 remove_wait_queue(&bp->wq, &wait); in wait_for_pin()
145 bp->waiting = 0; in wait_for_pin()
152 struct bbc_i2c_bus *bp = client->bp; in bbc_i2c_writeb() local
157 if (bp->i2c_bussel_reg != NULL) in bbc_i2c_writeb()
158 writeb(client->bus, bp->i2c_bussel_reg); in bbc_i2c_writeb()
160 writeb(address, bp->i2c_control_regs + 0x1); in bbc_i2c_writeb()
161 writeb(I2C_PCF_START, bp->i2c_control_regs + 0x0); in bbc_i2c_writeb()
162 if (wait_for_pin(bp, &status)) in bbc_i2c_writeb()
165 writeb(off, bp->i2c_control_regs + 0x1); in bbc_i2c_writeb()
166 if (wait_for_pin(bp, &status) || in bbc_i2c_writeb()
170 writeb(val, bp->i2c_control_regs + 0x1); in bbc_i2c_writeb()
171 if (wait_for_pin(bp, &status)) in bbc_i2c_writeb()
177 writeb(I2C_PCF_STOP, bp->i2c_control_regs + 0x0); in bbc_i2c_writeb()
183 struct bbc_i2c_bus *bp = client->bp; in bbc_i2c_readb() local
187 if (bp->i2c_bussel_reg != NULL) in bbc_i2c_readb()
188 writeb(client->bus, bp->i2c_bussel_reg); in bbc_i2c_readb()
190 writeb(address, bp->i2c_control_regs + 0x1); in bbc_i2c_readb()
191 writeb(I2C_PCF_START, bp->i2c_control_regs + 0x0); in bbc_i2c_readb()
192 if (wait_for_pin(bp, &status)) in bbc_i2c_readb()
195 writeb(off, bp->i2c_control_regs + 0x1); in bbc_i2c_readb()
196 if (wait_for_pin(bp, &status) || in bbc_i2c_readb()
200 writeb(I2C_PCF_STOP, bp->i2c_control_regs + 0x0); in bbc_i2c_readb()
204 writeb(address, bp->i2c_control_regs + 0x1); in bbc_i2c_readb()
205 writeb(I2C_PCF_START, bp->i2c_control_regs + 0x0); in bbc_i2c_readb()
206 if (wait_for_pin(bp, &status)) in bbc_i2c_readb()
212 (void) readb(bp->i2c_control_regs + 0x1); in bbc_i2c_readb()
213 if (wait_for_pin(bp, &status)) in bbc_i2c_readb()
216 writeb(I2C_PCF_ESO | I2C_PCF_ENI, bp->i2c_control_regs + 0x0); in bbc_i2c_readb()
217 *byte = readb(bp->i2c_control_regs + 0x1); in bbc_i2c_readb()
218 if (wait_for_pin(bp, &status)) in bbc_i2c_readb()
224 writeb(I2C_PCF_STOP, bp->i2c_control_regs + 0x0); in bbc_i2c_readb()
225 (void) readb(bp->i2c_control_regs + 0x1); in bbc_i2c_readb()
273 struct bbc_i2c_bus *bp = dev_id; in bbc_i2c_interrupt() local
278 if (bp->waiting && in bbc_i2c_interrupt()
279 !(readb(bp->i2c_control_regs + 0x0) & I2C_PCF_PIN)) in bbc_i2c_interrupt()
280 wake_up_interruptible(&bp->wq); in bbc_i2c_interrupt()
285 static void reset_one_i2c(struct bbc_i2c_bus *bp) in reset_one_i2c() argument
287 writeb(I2C_PCF_PIN, bp->i2c_control_regs + 0x0); in reset_one_i2c()
288 writeb(bp->own, bp->i2c_control_regs + 0x1); in reset_one_i2c()
289 writeb(I2C_PCF_PIN | I2C_PCF_ES1, bp->i2c_control_regs + 0x0); in reset_one_i2c()
290 writeb(bp->clock, bp->i2c_control_regs + 0x1); in reset_one_i2c()
291 writeb(I2C_PCF_IDLE, bp->i2c_control_regs + 0x0); in reset_one_i2c()
296 struct bbc_i2c_bus *bp; in attach_one_i2c() local
300 bp = kzalloc(sizeof(*bp), GFP_KERNEL); in attach_one_i2c()
301 if (!bp) in attach_one_i2c()
304 INIT_LIST_HEAD(&bp->temps); in attach_one_i2c()
305 INIT_LIST_HEAD(&bp->fans); in attach_one_i2c()
307 bp->i2c_control_regs = of_ioremap(&op->resource[0], 0, 0x2, "bbc_i2c_regs"); in attach_one_i2c()
308 if (!bp->i2c_control_regs) in attach_one_i2c()
312 bp->i2c_bussel_reg = of_ioremap(&op->resource[1], 0, 0x1, "bbc_i2c_bussel"); in attach_one_i2c()
313 if (!bp->i2c_bussel_reg) in attach_one_i2c()
317 bp->waiting = 0; in attach_one_i2c()
318 init_waitqueue_head(&bp->wq); in attach_one_i2c()
320 IRQF_SHARED, "bbc_i2c", bp)) in attach_one_i2c()
323 bp->index = index; in attach_one_i2c()
324 bp->op = op; in attach_one_i2c()
326 spin_lock_init(&bp->lock); in attach_one_i2c()
335 bp->devs[entry].device = child_op; in attach_one_i2c()
336 bp->devs[entry].client_claimed = 0; in attach_one_i2c()
339 writeb(I2C_PCF_PIN, bp->i2c_control_regs + 0x0); in attach_one_i2c()
340 bp->own = readb(bp->i2c_control_regs + 0x01); in attach_one_i2c()
341 writeb(I2C_PCF_PIN | I2C_PCF_ES1, bp->i2c_control_regs + 0x0); in attach_one_i2c()
342 bp->clock = readb(bp->i2c_control_regs + 0x01); in attach_one_i2c()
345 bp->index, bp->i2c_control_regs, entry, bp->own, bp->clock); in attach_one_i2c()
347 reset_one_i2c(bp); in attach_one_i2c()
349 return bp; in attach_one_i2c()
352 if (bp->i2c_bussel_reg) in attach_one_i2c()
353 of_iounmap(&op->resource[1], bp->i2c_bussel_reg, 1); in attach_one_i2c()
354 if (bp->i2c_control_regs) in attach_one_i2c()
355 of_iounmap(&op->resource[0], bp->i2c_control_regs, 2); in attach_one_i2c()
356 kfree(bp); in attach_one_i2c()
360 extern int bbc_envctrl_init(struct bbc_i2c_bus *bp);
361 extern void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp);
365 struct bbc_i2c_bus *bp; in bbc_i2c_probe() local
368 bp = attach_one_i2c(op, index); in bbc_i2c_probe()
369 if (!bp) in bbc_i2c_probe()
372 err = bbc_envctrl_init(bp); in bbc_i2c_probe()
374 free_irq(op->archdata.irqs[0], bp); in bbc_i2c_probe()
375 if (bp->i2c_bussel_reg) in bbc_i2c_probe()
376 of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1); in bbc_i2c_probe()
377 if (bp->i2c_control_regs) in bbc_i2c_probe()
378 of_iounmap(&op->resource[1], bp->i2c_control_regs, 2); in bbc_i2c_probe()
379 kfree(bp); in bbc_i2c_probe()
381 dev_set_drvdata(&op->dev, bp); in bbc_i2c_probe()
389 struct bbc_i2c_bus *bp = dev_get_drvdata(&op->dev); in bbc_i2c_remove() local
391 bbc_envctrl_cleanup(bp); in bbc_i2c_remove()
393 free_irq(op->archdata.irqs[0], bp); in bbc_i2c_remove()
395 if (bp->i2c_bussel_reg) in bbc_i2c_remove()
396 of_iounmap(&op->resource[0], bp->i2c_bussel_reg, 1); in bbc_i2c_remove()
397 if (bp->i2c_control_regs) in bbc_i2c_remove()
398 of_iounmap(&op->resource[1], bp->i2c_control_regs, 2); in bbc_i2c_remove()
400 kfree(bp); in bbc_i2c_remove()