Lines Matching refs:p2wi
84 struct p2wi { struct
96 struct p2wi *p2wi = dev_id; in p2wi_interrupt() argument
99 status = readl(p2wi->regs + P2WI_INTS); in p2wi_interrupt()
100 p2wi->status = status; in p2wi_interrupt()
105 writel(status, p2wi->regs + P2WI_INTS); in p2wi_interrupt()
107 complete(&p2wi->complete); in p2wi_interrupt()
121 struct p2wi *p2wi = i2c_get_adapdata(adap); in p2wi_smbus_xfer() local
124 if (p2wi->slave_addr >= 0 && addr != p2wi->slave_addr) { in p2wi_smbus_xfer()
132 writel(command, p2wi->regs + P2WI_DADDR0); in p2wi_smbus_xfer()
137 writel(data->byte, p2wi->regs + P2WI_DATA0); in p2wi_smbus_xfer()
139 writel(dlen, p2wi->regs + P2WI_DLEN); in p2wi_smbus_xfer()
141 if (readl(p2wi->regs + P2WI_CTRL) & P2WI_CTRL_START_TRANS) { in p2wi_smbus_xfer()
146 reinit_completion(&p2wi->complete); in p2wi_smbus_xfer()
149 p2wi->regs + P2WI_INTE); in p2wi_smbus_xfer()
152 p2wi->regs + P2WI_CTRL); in p2wi_smbus_xfer()
154 wait_for_completion(&p2wi->complete); in p2wi_smbus_xfer()
156 if (p2wi->status & P2WI_INTS_LOAD_BSY) { in p2wi_smbus_xfer()
161 if (p2wi->status & P2WI_INTS_TRANS_ERR) { in p2wi_smbus_xfer()
167 data->byte = readl(p2wi->regs + P2WI_DATA0); in p2wi_smbus_xfer()
190 struct p2wi *p2wi; in p2wi_probe() local
209 p2wi = devm_kzalloc(dev, sizeof(struct p2wi), GFP_KERNEL); in p2wi_probe()
210 if (!p2wi) in p2wi_probe()
213 p2wi->slave_addr = -1; in p2wi_probe()
230 p2wi->slave_addr = slave_addr; in p2wi_probe()
233 p2wi->regs = devm_platform_ioremap_resource(pdev, 0); in p2wi_probe()
234 if (IS_ERR(p2wi->regs)) in p2wi_probe()
235 return PTR_ERR(p2wi->regs); in p2wi_probe()
237 strscpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name)); in p2wi_probe()
242 p2wi->clk = devm_clk_get_enabled(dev, NULL); in p2wi_probe()
243 if (IS_ERR(p2wi->clk)) { in p2wi_probe()
244 ret = PTR_ERR(p2wi->clk); in p2wi_probe()
249 parent_clk_freq = clk_get_rate(p2wi->clk); in p2wi_probe()
251 p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL); in p2wi_probe()
252 if (IS_ERR(p2wi->rstc)) { in p2wi_probe()
254 p2wi->rstc); in p2wi_probe()
255 return PTR_ERR(p2wi->rstc); in p2wi_probe()
258 ret = reset_control_deassert(p2wi->rstc); in p2wi_probe()
264 init_completion(&p2wi->complete); in p2wi_probe()
265 p2wi->adapter.dev.parent = dev; in p2wi_probe()
266 p2wi->adapter.algo = &p2wi_algo; in p2wi_probe()
267 p2wi->adapter.owner = THIS_MODULE; in p2wi_probe()
268 p2wi->adapter.dev.of_node = pdev->dev.of_node; in p2wi_probe()
269 platform_set_drvdata(pdev, p2wi); in p2wi_probe()
270 i2c_set_adapdata(&p2wi->adapter, p2wi); in p2wi_probe()
272 ret = devm_request_irq(dev, irq, p2wi_interrupt, 0, pdev->name, p2wi); in p2wi_probe()
279 writel(P2WI_CTRL_SOFT_RST, p2wi->regs + P2WI_CTRL); in p2wi_probe()
295 p2wi->regs + P2WI_CCR); in p2wi_probe()
297 ret = i2c_add_adapter(&p2wi->adapter); in p2wi_probe()
302 reset_control_assert(p2wi->rstc); in p2wi_probe()
309 struct p2wi *p2wi = platform_get_drvdata(dev); in p2wi_remove() local
311 reset_control_assert(p2wi->rstc); in p2wi_remove()
312 i2c_del_adapter(&p2wi->adapter); in p2wi_remove()