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->target_addr >= 0 && addr != p2wi->target_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
214 p2wi = devm_kzalloc(dev, sizeof(struct p2wi), GFP_KERNEL); in p2wi_probe()
215 if (!p2wi) in p2wi_probe()
218 p2wi->target_addr = -1; in p2wi_probe()
235 p2wi->target_addr = target_addr; in p2wi_probe()
238 p2wi->regs = devm_platform_ioremap_resource(pdev, 0); in p2wi_probe()
239 if (IS_ERR(p2wi->regs)) in p2wi_probe()
240 return PTR_ERR(p2wi->regs); in p2wi_probe()
242 strscpy(p2wi->adapter.name, pdev->name, sizeof(p2wi->adapter.name)); in p2wi_probe()
247 p2wi->clk = devm_clk_get_enabled(dev, NULL); in p2wi_probe()
248 if (IS_ERR(p2wi->clk)) { in p2wi_probe()
249 ret = PTR_ERR(p2wi->clk); in p2wi_probe()
254 parent_clk_freq = clk_get_rate(p2wi->clk); in p2wi_probe()
256 p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL); in p2wi_probe()
257 if (IS_ERR(p2wi->rstc)) { in p2wi_probe()
259 p2wi->rstc); in p2wi_probe()
260 return PTR_ERR(p2wi->rstc); in p2wi_probe()
263 ret = reset_control_deassert(p2wi->rstc); in p2wi_probe()
269 init_completion(&p2wi->complete); in p2wi_probe()
270 p2wi->adapter.dev.parent = dev; in p2wi_probe()
271 p2wi->adapter.algo = &p2wi_algo; in p2wi_probe()
272 p2wi->adapter.owner = THIS_MODULE; in p2wi_probe()
273 p2wi->adapter.dev.of_node = pdev->dev.of_node; in p2wi_probe()
274 platform_set_drvdata(pdev, p2wi); in p2wi_probe()
275 i2c_set_adapdata(&p2wi->adapter, p2wi); in p2wi_probe()
277 ret = devm_request_irq(dev, irq, p2wi_interrupt, 0, pdev->name, p2wi); in p2wi_probe()
284 writel(P2WI_CTRL_SOFT_RST, p2wi->regs + P2WI_CTRL); in p2wi_probe()
300 p2wi->regs + P2WI_CCR); in p2wi_probe()
302 ret = i2c_add_adapter(&p2wi->adapter); in p2wi_probe()
307 reset_control_assert(p2wi->rstc); in p2wi_probe()
314 struct p2wi *p2wi = platform_get_drvdata(dev); in p2wi_remove() local
316 reset_control_assert(p2wi->rstc); in p2wi_remove()
317 i2c_del_adapter(&p2wi->adapter); in p2wi_remove()