Searched refs:i2c (Results 1 - 200 of 2306) sorted by relevance

1234567891011>>

/linux-4.4.14/drivers/i2c/busses/
H A DMakefile2 # Makefile for the i2c bus drivers.
6 obj-$(CONFIG_I2C_SCMI) += i2c-scmi.o
9 obj-$(CONFIG_I2C_ALI1535) += i2c-ali1535.o
10 obj-$(CONFIG_I2C_ALI1563) += i2c-ali1563.o
11 obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o
12 obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o
13 obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o
14 obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o
15 obj-$(CONFIG_I2C_I801) += i2c-i801.o
16 obj-$(CONFIG_I2C_ISCH) += i2c-isch.o
17 obj-$(CONFIG_I2C_ISMT) += i2c-ismt.o
18 obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o
19 obj-$(CONFIG_I2C_NFORCE2_S4985) += i2c-nforce2-s4985.o
20 obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o
21 obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o
22 obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o
23 obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o
24 obj-$(CONFIG_I2C_VIA) += i2c-via.o
25 obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o
28 obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
29 obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o
32 obj-$(CONFIG_I2C_AT91) += i2c-at91.o
33 obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
34 obj-$(CONFIG_I2C_AXXIA) += i2c-axxia.o
35 obj-$(CONFIG_I2C_BCM2835) += i2c-bcm2835.o
36 obj-$(CONFIG_I2C_BCM_IPROC) += i2c-bcm-iproc.o
37 obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
38 obj-$(CONFIG_I2C_CADENCE) += i2c-cadence.o
39 obj-$(CONFIG_I2C_CBUS_GPIO) += i2c-cbus-gpio.o
40 obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
41 obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
42 obj-$(CONFIG_I2C_DESIGNWARE_CORE) += i2c-designware-core.o
43 obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o
44 i2c-designware-platform-objs := i2c-designware-platdrv.o
45 i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o
46 obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o
47 i2c-designware-pci-objs := i2c-designware-pcidrv.o
48 obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.o
49 obj-$(CONFIG_I2C_EFM32) += i2c-efm32.o
50 obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
51 obj-$(CONFIG_I2C_EMEV2) += i2c-emev2.o
52 obj-$(CONFIG_I2C_EXYNOS5) += i2c-exynos5.o
53 obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
54 obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
55 obj-$(CONFIG_I2C_HIX5HD2) += i2c-hix5hd2.o
56 obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
57 obj-$(CONFIG_I2C_IMG) += i2c-img-scb.o
58 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
59 obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o
60 obj-$(CONFIG_I2C_JZ4780) += i2c-jz4780.o
61 obj-$(CONFIG_I2C_KEMPLD) += i2c-kempld.o
62 obj-$(CONFIG_I2C_LPC2K) += i2c-lpc2k.o
63 obj-$(CONFIG_I2C_MESON) += i2c-meson.o
64 obj-$(CONFIG_I2C_MPC) += i2c-mpc.o
65 obj-$(CONFIG_I2C_MT65XX) += i2c-mt65xx.o
66 obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o
67 obj-$(CONFIG_I2C_MXS) += i2c-mxs.o
68 obj-$(CONFIG_I2C_NOMADIK) += i2c-nomadik.o
69 obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o
70 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
71 obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o
72 obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pca-platform.o
73 obj-$(CONFIG_I2C_PMCMSP) += i2c-pmcmsp.o
74 obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
75 obj-$(CONFIG_I2C_PUV3) += i2c-puv3.o
76 obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
77 obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o
78 obj-$(CONFIG_I2C_QUP) += i2c-qup.o
79 obj-$(CONFIG_I2C_RIIC) += i2c-riic.o
80 obj-$(CONFIG_I2C_RK3X) += i2c-rk3x.o
81 obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o
82 obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o
83 obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o
84 obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
85 obj-$(CONFIG_I2C_SIRF) += i2c-sirf.o
86 obj-$(CONFIG_I2C_ST) += i2c-st.o
87 obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
88 obj-$(CONFIG_I2C_SUN6I_P2WI) += i2c-sun6i-p2wi.o
89 obj-$(CONFIG_I2C_TEGRA) += i2c-tegra.o
90 obj-$(CONFIG_I2C_UNIPHIER) += i2c-uniphier.o
91 obj-$(CONFIG_I2C_UNIPHIER_F) += i2c-uniphier-f.o
92 obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o
93 obj-$(CONFIG_I2C_WMT) += i2c-wmt.o
94 obj-$(CONFIG_I2C_OCTEON) += i2c-octeon.o
95 obj-$(CONFIG_I2C_XILINX) += i2c-xiic.o
96 obj-$(CONFIG_I2C_XLR) += i2c-xlr.o
97 obj-$(CONFIG_I2C_XLP9XX) += i2c-xlp9xx.o
98 obj-$(CONFIG_I2C_RCAR) += i2c-rcar.o
101 obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o
102 obj-$(CONFIG_I2C_DLN2) += i2c-dln2.o
103 obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
104 obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
105 obj-$(CONFIG_I2C_ROBOTFUZZ_OSIF) += i2c-robotfuzz-osif.o
106 obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o
107 obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o
108 obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o
111 obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o
112 obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o
113 obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o
114 obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o
115 obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
116 obj-$(CONFIG_I2C_OPAL) += i2c-opal.o
117 obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
118 obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
119 obj-$(CONFIG_I2C_XGENE_SLIMPRO) += i2c-xgene-slimpro.o
H A Di2c-meson.c13 #include <linux/i2c.h>
101 static void meson_i2c_set_mask(struct meson_i2c *i2c, int reg, u32 mask, meson_i2c_set_mask() argument
106 data = readl(i2c->regs + reg); meson_i2c_set_mask()
109 writel(data, i2c->regs + reg); meson_i2c_set_mask()
112 static void meson_i2c_reset_tokens(struct meson_i2c *i2c) meson_i2c_reset_tokens() argument
114 i2c->tokens[0] = 0; meson_i2c_reset_tokens()
115 i2c->tokens[1] = 0; meson_i2c_reset_tokens()
116 i2c->num_tokens = 0; meson_i2c_reset_tokens()
119 static void meson_i2c_add_token(struct meson_i2c *i2c, int token) meson_i2c_add_token() argument
121 if (i2c->num_tokens < 8) meson_i2c_add_token()
122 i2c->tokens[0] |= (token & 0xf) << (i2c->num_tokens * 4); meson_i2c_add_token()
124 i2c->tokens[1] |= (token & 0xf) << ((i2c->num_tokens % 8) * 4); meson_i2c_add_token()
126 i2c->num_tokens++; meson_i2c_add_token()
129 static void meson_i2c_write_tokens(struct meson_i2c *i2c) meson_i2c_write_tokens() argument
131 writel(i2c->tokens[0], i2c->regs + REG_TOK_LIST0); meson_i2c_write_tokens()
132 writel(i2c->tokens[1], i2c->regs + REG_TOK_LIST1); meson_i2c_write_tokens()
135 static void meson_i2c_set_clk_div(struct meson_i2c *i2c) meson_i2c_set_clk_div() argument
137 unsigned long clk_rate = clk_get_rate(i2c->clk); meson_i2c_set_clk_div()
140 div = DIV_ROUND_UP(clk_rate, i2c->frequency * 4); meson_i2c_set_clk_div()
141 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_CLKDIV_MASK, meson_i2c_set_clk_div()
144 dev_dbg(i2c->dev, "%s: clk %lu, freq %u, div %u\n", __func__, meson_i2c_set_clk_div()
145 clk_rate, i2c->frequency, div); meson_i2c_set_clk_div()
148 static void meson_i2c_get_data(struct meson_i2c *i2c, char *buf, int len) meson_i2c_get_data() argument
153 rdata0 = readl(i2c->regs + REG_TOK_RDATA0); meson_i2c_get_data()
154 rdata1 = readl(i2c->regs + REG_TOK_RDATA1); meson_i2c_get_data()
156 dev_dbg(i2c->dev, "%s: data %08x %08x len %d\n", __func__, meson_i2c_get_data()
166 static void meson_i2c_put_data(struct meson_i2c *i2c, char *buf, int len) meson_i2c_put_data() argument
177 writel(wdata0, i2c->regs + REG_TOK_WDATA0); meson_i2c_put_data()
178 writel(wdata0, i2c->regs + REG_TOK_WDATA1); meson_i2c_put_data()
180 dev_dbg(i2c->dev, "%s: data %08x %08x len %d\n", __func__, meson_i2c_put_data()
184 static void meson_i2c_prepare_xfer(struct meson_i2c *i2c) meson_i2c_prepare_xfer() argument
186 bool write = !(i2c->msg->flags & I2C_M_RD); meson_i2c_prepare_xfer()
189 i2c->count = min_t(int, i2c->msg->len - i2c->pos, 8); meson_i2c_prepare_xfer()
191 for (i = 0; i < i2c->count - 1; i++) meson_i2c_prepare_xfer()
192 meson_i2c_add_token(i2c, TOKEN_DATA); meson_i2c_prepare_xfer()
194 if (i2c->count) { meson_i2c_prepare_xfer()
195 if (write || i2c->pos + i2c->count < i2c->msg->len) meson_i2c_prepare_xfer()
196 meson_i2c_add_token(i2c, TOKEN_DATA); meson_i2c_prepare_xfer()
198 meson_i2c_add_token(i2c, TOKEN_DATA_LAST); meson_i2c_prepare_xfer()
202 meson_i2c_put_data(i2c, i2c->msg->buf + i2c->pos, i2c->count); meson_i2c_prepare_xfer()
205 static void meson_i2c_stop(struct meson_i2c *i2c) meson_i2c_stop() argument
207 dev_dbg(i2c->dev, "%s: last %d\n", __func__, i2c->last); meson_i2c_stop()
209 if (i2c->last) { meson_i2c_stop()
210 i2c->state = STATE_STOP; meson_i2c_stop()
211 meson_i2c_add_token(i2c, TOKEN_STOP); meson_i2c_stop()
213 i2c->state = STATE_IDLE; meson_i2c_stop()
214 complete_all(&i2c->done); meson_i2c_stop()
220 struct meson_i2c *i2c = dev_id; meson_i2c_irq() local
223 spin_lock(&i2c->lock); meson_i2c_irq()
225 meson_i2c_reset_tokens(i2c); meson_i2c_irq()
226 ctrl = readl(i2c->regs + REG_CTRL); meson_i2c_irq()
228 dev_dbg(i2c->dev, "irq: state %d, pos %d, count %d, ctrl %08x\n", meson_i2c_irq()
229 i2c->state, i2c->pos, i2c->count, ctrl); meson_i2c_irq()
231 if (ctrl & REG_CTRL_ERROR && i2c->state != STATE_IDLE) { meson_i2c_irq()
238 dev_dbg(i2c->dev, "error bit set\n"); meson_i2c_irq()
239 i2c->error = -ENXIO; meson_i2c_irq()
240 i2c->state = STATE_IDLE; meson_i2c_irq()
241 complete_all(&i2c->done); meson_i2c_irq()
245 switch (i2c->state) { meson_i2c_irq()
247 if (i2c->count > 0) { meson_i2c_irq()
248 meson_i2c_get_data(i2c, i2c->msg->buf + i2c->pos, meson_i2c_irq()
249 i2c->count); meson_i2c_irq()
250 i2c->pos += i2c->count; meson_i2c_irq()
253 if (i2c->pos >= i2c->msg->len) { meson_i2c_irq()
254 meson_i2c_stop(i2c); meson_i2c_irq()
258 meson_i2c_prepare_xfer(i2c); meson_i2c_irq()
261 i2c->pos += i2c->count; meson_i2c_irq()
263 if (i2c->pos >= i2c->msg->len) { meson_i2c_irq()
264 meson_i2c_stop(i2c); meson_i2c_irq()
268 meson_i2c_prepare_xfer(i2c); meson_i2c_irq()
271 i2c->state = STATE_IDLE; meson_i2c_irq()
272 complete_all(&i2c->done); meson_i2c_irq()
279 if (i2c->state != STATE_IDLE) { meson_i2c_irq()
281 meson_i2c_write_tokens(i2c); meson_i2c_irq()
282 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0); meson_i2c_irq()
283 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, meson_i2c_irq()
287 spin_unlock(&i2c->lock); meson_i2c_irq()
292 static void meson_i2c_do_start(struct meson_i2c *i2c, struct i2c_msg *msg) meson_i2c_do_start() argument
299 writel(msg->addr << 1, i2c->regs + REG_SLAVE_ADDR); meson_i2c_do_start()
300 meson_i2c_add_token(i2c, TOKEN_START); meson_i2c_do_start()
301 meson_i2c_add_token(i2c, token); meson_i2c_do_start()
304 static int meson_i2c_xfer_msg(struct meson_i2c *i2c, struct i2c_msg *msg, meson_i2c_xfer_msg() argument
310 i2c->msg = msg; meson_i2c_xfer_msg()
311 i2c->last = last; meson_i2c_xfer_msg()
312 i2c->pos = 0; meson_i2c_xfer_msg()
313 i2c->count = 0; meson_i2c_xfer_msg()
314 i2c->error = 0; meson_i2c_xfer_msg()
316 meson_i2c_reset_tokens(i2c); meson_i2c_xfer_msg()
319 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_ACK_IGNORE, flags); meson_i2c_xfer_msg()
322 meson_i2c_do_start(i2c, msg); meson_i2c_xfer_msg()
324 i2c->state = (msg->flags & I2C_M_RD) ? STATE_READ : STATE_WRITE; meson_i2c_xfer_msg()
325 meson_i2c_prepare_xfer(i2c); meson_i2c_xfer_msg()
326 meson_i2c_write_tokens(i2c); meson_i2c_xfer_msg()
327 reinit_completion(&i2c->done); meson_i2c_xfer_msg()
330 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, REG_CTRL_START); meson_i2c_xfer_msg()
333 time_left = wait_for_completion_timeout(&i2c->done, time_left); meson_i2c_xfer_msg()
336 * Protect access to i2c struct and registers from interrupt meson_i2c_xfer_msg()
340 spin_lock_irqsave(&i2c->lock, flags); meson_i2c_xfer_msg()
343 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0); meson_i2c_xfer_msg()
346 i2c->state = STATE_IDLE; meson_i2c_xfer_msg()
350 if (i2c->error) meson_i2c_xfer_msg()
351 ret = i2c->error; meson_i2c_xfer_msg()
353 spin_unlock_irqrestore(&i2c->lock, flags); meson_i2c_xfer_msg()
361 struct meson_i2c *i2c = adap->algo_data; meson_i2c_xfer() local
364 clk_enable(i2c->clk); meson_i2c_xfer()
365 meson_i2c_set_clk_div(i2c); meson_i2c_xfer()
368 ret = meson_i2c_xfer_msg(i2c, msgs + i, i == num - 1); meson_i2c_xfer()
374 clk_disable(i2c->clk); meson_i2c_xfer()
392 struct meson_i2c *i2c; meson_i2c_probe() local
396 i2c = devm_kzalloc(&pdev->dev, sizeof(struct meson_i2c), GFP_KERNEL); meson_i2c_probe()
397 if (!i2c) meson_i2c_probe()
401 &i2c->frequency)) meson_i2c_probe()
402 i2c->frequency = DEFAULT_FREQ; meson_i2c_probe()
404 i2c->dev = &pdev->dev; meson_i2c_probe()
405 platform_set_drvdata(pdev, i2c); meson_i2c_probe()
407 spin_lock_init(&i2c->lock); meson_i2c_probe()
408 init_completion(&i2c->done); meson_i2c_probe()
410 i2c->clk = devm_clk_get(&pdev->dev, NULL); meson_i2c_probe()
411 if (IS_ERR(i2c->clk)) { meson_i2c_probe()
413 return PTR_ERR(i2c->clk); meson_i2c_probe()
417 i2c->regs = devm_ioremap_resource(&pdev->dev, mem); meson_i2c_probe()
418 if (IS_ERR(i2c->regs)) meson_i2c_probe()
419 return PTR_ERR(i2c->regs); meson_i2c_probe()
421 i2c->irq = platform_get_irq(pdev, 0); meson_i2c_probe()
422 if (i2c->irq < 0) { meson_i2c_probe()
424 return i2c->irq; meson_i2c_probe()
427 ret = devm_request_irq(&pdev->dev, i2c->irq, meson_i2c_irq, meson_i2c_probe()
428 0, dev_name(&pdev->dev), i2c); meson_i2c_probe()
434 ret = clk_prepare(i2c->clk); meson_i2c_probe()
440 strlcpy(i2c->adap.name, "Meson I2C adapter", meson_i2c_probe()
441 sizeof(i2c->adap.name)); meson_i2c_probe()
442 i2c->adap.owner = THIS_MODULE; meson_i2c_probe()
443 i2c->adap.algo = &meson_i2c_algorithm; meson_i2c_probe()
444 i2c->adap.dev.parent = &pdev->dev; meson_i2c_probe()
445 i2c->adap.dev.of_node = np; meson_i2c_probe()
446 i2c->adap.algo_data = i2c; meson_i2c_probe()
452 meson_i2c_set_mask(i2c, REG_CTRL, REG_CTRL_START, 0); meson_i2c_probe()
454 ret = i2c_add_adapter(&i2c->adap); meson_i2c_probe()
457 clk_unprepare(i2c->clk); meson_i2c_probe()
466 struct meson_i2c *i2c = platform_get_drvdata(pdev); meson_i2c_remove() local
468 i2c_del_adapter(&i2c->adap); meson_i2c_remove()
469 clk_unprepare(i2c->clk); meson_i2c_remove()
475 { .compatible = "amlogic,meson6-i2c" },
484 .name = "meson-i2c",
H A Di2c-digicolor.c16 #include <linux/i2c.h>
75 static void dc_i2c_cmd(struct dc_i2c *i2c, u8 cmd) dc_i2c_cmd() argument
77 writeb_relaxed(cmd | II_COMMAND_GO, i2c->regs + II_COMMAND); dc_i2c_cmd()
90 static void dc_i2c_data(struct dc_i2c *i2c, u8 data) dc_i2c_data() argument
92 writeb_relaxed(data, i2c->regs + II_DATA); dc_i2c_data()
95 static void dc_i2c_write_byte(struct dc_i2c *i2c, u8 byte) dc_i2c_write_byte() argument
97 dc_i2c_data(i2c, byte); dc_i2c_write_byte()
98 dc_i2c_cmd(i2c, II_CMD_SEND_ACK); dc_i2c_write_byte()
101 static void dc_i2c_write_buf(struct dc_i2c *i2c) dc_i2c_write_buf() argument
103 dc_i2c_write_byte(i2c, i2c->msg->buf[i2c->msgbuf_ptr++]); dc_i2c_write_buf()
106 static void dc_i2c_next_read(struct dc_i2c *i2c) dc_i2c_next_read() argument
108 bool last = (i2c->msgbuf_ptr + 1 == i2c->msg->len); dc_i2c_next_read()
110 dc_i2c_cmd(i2c, last ? II_CMD_GET_NOACK : II_CMD_GET_ACK); dc_i2c_next_read()
113 static void dc_i2c_stop(struct dc_i2c *i2c) dc_i2c_stop() argument
115 i2c->state = STATE_STOP; dc_i2c_stop()
116 if (i2c->last) dc_i2c_stop()
117 dc_i2c_cmd(i2c, II_CMD_STOP); dc_i2c_stop()
119 complete(&i2c->done); dc_i2c_stop()
122 static u8 dc_i2c_read_byte(struct dc_i2c *i2c) dc_i2c_read_byte() argument
124 return readb_relaxed(i2c->regs + II_DATA); dc_i2c_read_byte()
127 static void dc_i2c_read_buf(struct dc_i2c *i2c) dc_i2c_read_buf() argument
129 i2c->msg->buf[i2c->msgbuf_ptr++] = dc_i2c_read_byte(i2c); dc_i2c_read_buf()
130 dc_i2c_next_read(i2c); dc_i2c_read_buf()
133 static void dc_i2c_set_irq(struct dc_i2c *i2c, int enable) dc_i2c_set_irq() argument
136 writeb_relaxed(1, i2c->regs + II_INTFLAG_CLEAR); dc_i2c_set_irq()
137 writeb_relaxed(!!enable, i2c->regs + II_INTENABLE); dc_i2c_set_irq()
140 static int dc_i2c_cmd_status(struct dc_i2c *i2c) dc_i2c_cmd_status() argument
142 u8 cmd = readb_relaxed(i2c->regs + II_COMMAND); dc_i2c_cmd_status()
147 static void dc_i2c_start_msg(struct dc_i2c *i2c, int first) dc_i2c_start_msg() argument
149 struct i2c_msg *msg = i2c->msg; dc_i2c_start_msg()
152 i2c->state = STATE_START; dc_i2c_start_msg()
153 dc_i2c_cmd(i2c, first ? II_CMD_START : II_CMD_RESTART); dc_i2c_start_msg()
155 i2c->state = STATE_READ; dc_i2c_start_msg()
156 dc_i2c_next_read(i2c); dc_i2c_start_msg()
158 i2c->state = STATE_WRITE; dc_i2c_start_msg()
159 dc_i2c_write_buf(i2c); dc_i2c_start_msg()
165 struct dc_i2c *i2c = dev_id; dc_i2c_irq() local
166 int cmd_status = dc_i2c_cmd_status(i2c); dc_i2c_irq()
170 writeb_relaxed(1, i2c->regs + II_INTFLAG_CLEAR); dc_i2c_irq()
172 spin_lock_irqsave(&i2c->lock, flags); dc_i2c_irq()
176 i2c->error = -EIO; dc_i2c_irq()
177 complete(&i2c->done); dc_i2c_irq()
181 switch (i2c->state) { dc_i2c_irq()
183 addr_cmd = dc_i2c_addr_cmd(i2c->msg); dc_i2c_irq()
184 dc_i2c_write_byte(i2c, addr_cmd); dc_i2c_irq()
185 i2c->state = STATE_ADDR; dc_i2c_irq()
188 if (i2c->msg->flags & I2C_M_RD) { dc_i2c_irq()
189 dc_i2c_next_read(i2c); dc_i2c_irq()
190 i2c->state = STATE_READ; dc_i2c_irq()
193 i2c->state = STATE_WRITE; dc_i2c_irq()
196 if (i2c->msgbuf_ptr < i2c->msg->len) dc_i2c_irq()
197 dc_i2c_write_buf(i2c); dc_i2c_irq()
199 dc_i2c_stop(i2c); dc_i2c_irq()
202 if (i2c->msgbuf_ptr < i2c->msg->len) dc_i2c_irq()
203 dc_i2c_read_buf(i2c); dc_i2c_irq()
205 dc_i2c_stop(i2c); dc_i2c_irq()
208 i2c->state = STATE_IDLE; dc_i2c_irq()
209 complete(&i2c->done); dc_i2c_irq()
214 spin_unlock_irqrestore(&i2c->lock, flags); dc_i2c_irq()
218 static int dc_i2c_xfer_msg(struct dc_i2c *i2c, struct i2c_msg *msg, int first, dc_i2c_xfer_msg() argument
224 spin_lock_irqsave(&i2c->lock, flags); dc_i2c_xfer_msg()
225 i2c->msg = msg; dc_i2c_xfer_msg()
226 i2c->msgbuf_ptr = 0; dc_i2c_xfer_msg()
227 i2c->last = last; dc_i2c_xfer_msg()
228 i2c->error = 0; dc_i2c_xfer_msg()
230 reinit_completion(&i2c->done); dc_i2c_xfer_msg()
231 dc_i2c_set_irq(i2c, 1); dc_i2c_xfer_msg()
232 dc_i2c_start_msg(i2c, first); dc_i2c_xfer_msg()
233 spin_unlock_irqrestore(&i2c->lock, flags); dc_i2c_xfer_msg()
235 timeout = wait_for_completion_timeout(&i2c->done, timeout); dc_i2c_xfer_msg()
236 dc_i2c_set_irq(i2c, 0); dc_i2c_xfer_msg()
238 i2c->state = STATE_IDLE; dc_i2c_xfer_msg()
242 if (i2c->error) dc_i2c_xfer_msg()
243 return i2c->error; dc_i2c_xfer_msg()
250 struct dc_i2c *i2c = adap->algo_data; dc_i2c_xfer() local
254 ret = dc_i2c_xfer_msg(i2c, &msgs[i], i == 0, i == num - 1); dc_i2c_xfer()
262 static int dc_i2c_init_hw(struct dc_i2c *i2c) dc_i2c_init_hw() argument
264 unsigned long clk_rate = clk_get_rate(i2c->clk); dc_i2c_init_hw()
267 writeb_relaxed(II_CONTROL_LOCAL_RESET, i2c->regs + II_CONTROL); dc_i2c_init_hw()
269 writeb_relaxed(0, i2c->regs + II_CONTROL); dc_i2c_init_hw()
272 clocktime = DIV_ROUND_UP(clk_rate, 64 * i2c->frequency); dc_i2c_init_hw()
274 dev_err(i2c->dev, "can't set bus speed of %u Hz\n", dc_i2c_init_hw()
275 i2c->frequency); dc_i2c_init_hw()
278 writeb_relaxed(clocktime - 1, i2c->regs + II_CLOCKTIME); dc_i2c_init_hw()
296 struct dc_i2c *i2c; dc_i2c_probe() local
300 i2c = devm_kzalloc(&pdev->dev, sizeof(struct dc_i2c), GFP_KERNEL); dc_i2c_probe()
301 if (!i2c) dc_i2c_probe()
305 &i2c->frequency)) dc_i2c_probe()
306 i2c->frequency = DEFAULT_FREQ; dc_i2c_probe()
308 i2c->dev = &pdev->dev; dc_i2c_probe()
309 platform_set_drvdata(pdev, i2c); dc_i2c_probe()
311 spin_lock_init(&i2c->lock); dc_i2c_probe()
312 init_completion(&i2c->done); dc_i2c_probe()
314 i2c->clk = devm_clk_get(&pdev->dev, NULL); dc_i2c_probe()
315 if (IS_ERR(i2c->clk)) dc_i2c_probe()
316 return PTR_ERR(i2c->clk); dc_i2c_probe()
319 i2c->regs = devm_ioremap_resource(&pdev->dev, r); dc_i2c_probe()
320 if (IS_ERR(i2c->regs)) dc_i2c_probe()
321 return PTR_ERR(i2c->regs); dc_i2c_probe()
328 dev_name(&pdev->dev), i2c); dc_i2c_probe()
332 strlcpy(i2c->adap.name, "Conexant Digicolor I2C adapter", dc_i2c_probe()
333 sizeof(i2c->adap.name)); dc_i2c_probe()
334 i2c->adap.owner = THIS_MODULE; dc_i2c_probe()
335 i2c->adap.algo = &dc_i2c_algorithm; dc_i2c_probe()
336 i2c->adap.dev.parent = &pdev->dev; dc_i2c_probe()
337 i2c->adap.dev.of_node = np; dc_i2c_probe()
338 i2c->adap.algo_data = i2c; dc_i2c_probe()
340 ret = dc_i2c_init_hw(i2c); dc_i2c_probe()
344 ret = clk_prepare_enable(i2c->clk); dc_i2c_probe()
348 ret = i2c_add_adapter(&i2c->adap); dc_i2c_probe()
350 clk_unprepare(i2c->clk); dc_i2c_probe()
359 struct dc_i2c *i2c = platform_get_drvdata(pdev); dc_i2c_remove() local
361 i2c_del_adapter(&i2c->adap); dc_i2c_remove()
362 clk_disable_unprepare(i2c->clk); dc_i2c_remove()
368 { .compatible = "cnxt,cx92755-i2c" },
376 .name = "digicolor-i2c",
H A Di2c-pxa.c24 #include <linux/i2c.h>
31 #include <linux/i2c-pxa.h>
39 #include <linux/i2c/pxa-i2c.h>
97 { "pxa2xx-i2c", REGS_PXA2XX },
99 { "ce4100-i2c", REGS_CE4100 },
100 { "pxa910-i2c", REGS_PXA910 },
198 #define _IBMR(i2c) ((i2c)->reg_ibmr)
199 #define _IDBR(i2c) ((i2c)->reg_idbr)
200 #define _ICR(i2c) ((i2c)->reg_icr)
201 #define _ISR(i2c) ((i2c)->reg_isr)
202 #define _ISAR(i2c) ((i2c)->reg_isar)
203 #define _ILCR(i2c) ((i2c)->reg_ilcr)
204 #define _IWCR(i2c) ((i2c)->reg_iwcr)
280 static void i2c_pxa_show_state(struct pxa_i2c *i2c, int lno, const char *fname) i2c_pxa_show_state() argument
282 dev_dbg(&i2c->adap.dev, "state:%s:%d: ISR=%08x, ICR=%08x, IBMR=%02x\n", fname, lno, i2c_pxa_show_state()
283 readl(_ISR(i2c)), readl(_ICR(i2c)), readl(_IBMR(i2c))); i2c_pxa_show_state()
286 #define show_state(i2c) i2c_pxa_show_state(i2c, __LINE__, __func__)
288 static void i2c_pxa_scream_blue_murder(struct pxa_i2c *i2c, const char *why) i2c_pxa_scream_blue_murder() argument
291 struct device *dev = &i2c->adap.dev; i2c_pxa_scream_blue_murder()
294 i2c->req_slave_addr >> 1, why); i2c_pxa_scream_blue_murder()
296 i2c->msg_num, i2c->msg_idx, i2c->msg_ptr); i2c_pxa_scream_blue_murder()
298 readl(_IBMR(i2c)), readl(_IDBR(i2c)), readl(_ICR(i2c)), i2c_pxa_scream_blue_murder()
299 readl(_ISR(i2c))); i2c_pxa_scream_blue_murder()
301 for (i = 0; i < i2c->irqlogidx; i++) i2c_pxa_scream_blue_murder()
302 pr_debug("[%08x:%08x] ", i2c->isrlog[i], i2c->icrlog[i]); i2c_pxa_scream_blue_murder()
311 #define show_state(i2c) do { } while (0)
314 #define i2c_pxa_scream_blue_murder(i2c, why) do { } while (0)
318 static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret);
321 static inline int i2c_pxa_is_slavemode(struct pxa_i2c *i2c) i2c_pxa_is_slavemode() argument
323 return !(readl(_ICR(i2c)) & ICR_SCLE); i2c_pxa_is_slavemode()
326 static void i2c_pxa_abort(struct pxa_i2c *i2c) i2c_pxa_abort() argument
330 if (i2c_pxa_is_slavemode(i2c)) { i2c_pxa_abort()
331 dev_dbg(&i2c->adap.dev, "%s: called in slave mode\n", __func__); i2c_pxa_abort()
335 while ((i > 0) && (readl(_IBMR(i2c)) & 0x1) == 0) { i2c_pxa_abort()
336 unsigned long icr = readl(_ICR(i2c)); i2c_pxa_abort()
341 writel(icr, _ICR(i2c)); i2c_pxa_abort()
343 show_state(i2c); i2c_pxa_abort()
349 writel(readl(_ICR(i2c)) & ~(ICR_MA | ICR_START | ICR_STOP), i2c_pxa_abort()
350 _ICR(i2c)); i2c_pxa_abort()
353 static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c) i2c_pxa_wait_bus_not_busy() argument
357 while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) { i2c_pxa_wait_bus_not_busy()
358 if ((readl(_ISR(i2c)) & ISR_SAD) != 0) i2c_pxa_wait_bus_not_busy()
362 show_state(i2c); i2c_pxa_wait_bus_not_busy()
366 show_state(i2c); i2c_pxa_wait_bus_not_busy()
371 static int i2c_pxa_wait_master(struct pxa_i2c *i2c) i2c_pxa_wait_master() argument
377 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", i2c_pxa_wait_master()
378 __func__, (long)jiffies, readl(_ISR(i2c)), readl(_ICR(i2c)), readl(_IBMR(i2c))); i2c_pxa_wait_master()
380 if (readl(_ISR(i2c)) & ISR_SAD) { i2c_pxa_wait_master()
382 dev_dbg(&i2c->adap.dev, "%s: Slave detected\n", __func__); i2c_pxa_wait_master()
387 * quick check of the i2c lines themselves to ensure they've i2c_pxa_wait_master()
390 if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) == 0 && readl(_IBMR(i2c)) == 3) { i2c_pxa_wait_master()
392 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__); i2c_pxa_wait_master()
400 dev_dbg(&i2c->adap.dev, "%s: did not free\n", __func__); i2c_pxa_wait_master()
405 static int i2c_pxa_set_master(struct pxa_i2c *i2c) i2c_pxa_set_master() argument
408 dev_dbg(&i2c->adap.dev, "setting to bus master\n"); i2c_pxa_set_master()
410 if ((readl(_ISR(i2c)) & (ISR_UB | ISR_IBB)) != 0) { i2c_pxa_set_master()
411 dev_dbg(&i2c->adap.dev, "%s: unit is busy\n", __func__); i2c_pxa_set_master()
412 if (!i2c_pxa_wait_master(i2c)) { i2c_pxa_set_master()
413 dev_dbg(&i2c->adap.dev, "%s: error: unit busy\n", __func__); i2c_pxa_set_master()
418 writel(readl(_ICR(i2c)) | ICR_SCLE, _ICR(i2c)); i2c_pxa_set_master()
423 static int i2c_pxa_wait_slave(struct pxa_i2c *i2c) i2c_pxa_wait_slave() argument
429 show_state(i2c); i2c_pxa_wait_slave()
433 dev_dbg(&i2c->adap.dev, "%s: %ld: ISR=%08x, ICR=%08x, IBMR=%02x\n", i2c_pxa_wait_slave()
434 __func__, (long)jiffies, readl(_ISR(i2c)), readl(_ICR(i2c)), readl(_IBMR(i2c))); i2c_pxa_wait_slave()
436 if ((readl(_ISR(i2c)) & (ISR_UB|ISR_IBB)) == 0 || i2c_pxa_wait_slave()
437 (readl(_ISR(i2c)) & ISR_SAD) != 0 || i2c_pxa_wait_slave()
438 (readl(_ICR(i2c)) & ICR_SCLE) == 0) { i2c_pxa_wait_slave()
440 dev_dbg(&i2c->adap.dev, "%s: done\n", __func__); i2c_pxa_wait_slave()
448 dev_dbg(&i2c->adap.dev, "%s: did not free\n", __func__); i2c_pxa_wait_slave()
456 static void i2c_pxa_set_slave(struct pxa_i2c *i2c, int errcode) i2c_pxa_set_slave() argument
458 show_state(i2c); i2c_pxa_set_slave()
466 if (readl(_ICR(i2c)) & ICR_STOP) { i2c_pxa_set_slave()
468 writel(readl(_ICR(i2c)) & ~ICR_STOP, _ICR(i2c)); i2c_pxa_set_slave()
471 if (!i2c_pxa_wait_slave(i2c)) { i2c_pxa_set_slave()
472 dev_err(&i2c->adap.dev, "%s: wait timedout\n", i2c_pxa_set_slave()
478 writel(readl(_ICR(i2c)) & ~(ICR_STOP|ICR_ACKNAK|ICR_MA), _ICR(i2c)); i2c_pxa_set_slave()
479 writel(readl(_ICR(i2c)) & ~ICR_SCLE, _ICR(i2c)); i2c_pxa_set_slave()
482 dev_dbg(&i2c->adap.dev, "ICR now %08x, ISR %08x\n", readl(_ICR(i2c)), readl(_ISR(i2c))); i2c_pxa_set_slave()
483 decode_ICR(readl(_ICR(i2c))); i2c_pxa_set_slave()
487 #define i2c_pxa_set_slave(i2c, err) do { } while (0)
490 static void i2c_pxa_reset(struct pxa_i2c *i2c) i2c_pxa_reset() argument
495 i2c_pxa_abort(i2c); i2c_pxa_reset()
498 writel(ICR_UR, _ICR(i2c)); i2c_pxa_reset()
499 writel(I2C_ISR_INIT, _ISR(i2c)); i2c_pxa_reset()
500 writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c)); i2c_pxa_reset()
502 if (i2c->reg_isar && IS_ENABLED(CONFIG_I2C_PXA_SLAVE)) i2c_pxa_reset()
503 writel(i2c->slave_addr, _ISAR(i2c)); i2c_pxa_reset()
506 writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c)); i2c_pxa_reset()
507 writel(readl(_ICR(i2c)) | (i2c->high_mode ? ICR_HS : 0), _ICR(i2c)); i2c_pxa_reset()
510 dev_info(&i2c->adap.dev, "Enabling slave mode\n"); i2c_pxa_reset()
511 writel(readl(_ICR(i2c)) | ICR_SADIE | ICR_ALDIE | ICR_SSDIE, _ICR(i2c)); i2c_pxa_reset()
514 i2c_pxa_set_slave(i2c, 0); i2c_pxa_reset()
517 writel(readl(_ICR(i2c)) | ICR_IUE, _ICR(i2c)); i2c_pxa_reset()
527 static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr) i2c_pxa_slave_txempty() argument
534 if (i2c->slave != NULL) i2c_pxa_slave_txempty()
535 ret = i2c->slave->read(i2c->slave->data); i2c_pxa_slave_txempty()
537 writel(ret, _IDBR(i2c)); i2c_pxa_slave_txempty()
538 writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); /* allow next byte */ i2c_pxa_slave_txempty()
542 static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr) i2c_pxa_slave_rxfull() argument
544 unsigned int byte = readl(_IDBR(i2c)); i2c_pxa_slave_rxfull()
546 if (i2c->slave != NULL) i2c_pxa_slave_rxfull()
547 i2c->slave->write(i2c->slave->data, byte); i2c_pxa_slave_rxfull()
549 writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); i2c_pxa_slave_rxfull()
552 static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) i2c_pxa_slave_start() argument
557 dev_dbg(&i2c->adap.dev, "SAD, mode is slave-%cx\n", i2c_pxa_slave_start()
560 if (i2c->slave != NULL) i2c_pxa_slave_start()
561 i2c->slave->event(i2c->slave->data, i2c_pxa_slave_start()
569 writel(readl(_ICR(i2c)) & ~(ICR_START|ICR_STOP), _ICR(i2c)); i2c_pxa_slave_start()
570 writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); i2c_pxa_slave_start()
575 if ((readl(_IBMR(i2c)) & 2) == 2) i2c_pxa_slave_start()
581 dev_err(&i2c->adap.dev, "timeout waiting for SCL high\n"); i2c_pxa_slave_start()
586 writel(readl(_ICR(i2c)) & ~ICR_SCLE, _ICR(i2c)); i2c_pxa_slave_start()
589 static void i2c_pxa_slave_stop(struct pxa_i2c *i2c) i2c_pxa_slave_stop() argument
592 dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop)\n"); i2c_pxa_slave_stop()
594 if (i2c->slave != NULL) i2c_pxa_slave_stop()
595 i2c->slave->event(i2c->slave->data, I2C_SLAVE_EVENT_STOP); i2c_pxa_slave_stop()
598 dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop) acked\n"); i2c_pxa_slave_stop()
604 if (i2c->msg) i2c_pxa_slave_stop()
605 i2c_pxa_master_complete(i2c, I2C_RETRY); i2c_pxa_slave_stop()
608 static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr) i2c_pxa_slave_txempty() argument
613 writel(0, _IDBR(i2c)); i2c_pxa_slave_txempty()
614 writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); i2c_pxa_slave_txempty()
618 static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr) i2c_pxa_slave_rxfull() argument
620 writel(readl(_ICR(i2c)) | ICR_TB | ICR_ACKNAK, _ICR(i2c)); i2c_pxa_slave_rxfull()
623 static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) i2c_pxa_slave_start() argument
632 writel(readl(_ICR(i2c)) & ~(ICR_START|ICR_STOP), _ICR(i2c)); i2c_pxa_slave_start()
633 writel(readl(_ICR(i2c)) | ICR_TB | ICR_ACKNAK, _ICR(i2c)); i2c_pxa_slave_start()
638 if ((readl(_IBMR(i2c)) & 2) == 2) i2c_pxa_slave_start()
644 dev_err(&i2c->adap.dev, "timeout waiting for SCL high\n"); i2c_pxa_slave_start()
649 writel(readl(_ICR(i2c)) & ~ICR_SCLE, _ICR(i2c)); i2c_pxa_slave_start()
652 static void i2c_pxa_slave_stop(struct pxa_i2c *i2c) i2c_pxa_slave_stop() argument
654 if (i2c->msg) i2c_pxa_slave_stop()
655 i2c_pxa_master_complete(i2c, I2C_RETRY); i2c_pxa_slave_stop()
673 static inline void i2c_pxa_start_message(struct pxa_i2c *i2c) i2c_pxa_start_message() argument
680 writel(i2c_pxa_addr_byte(i2c->msg), _IDBR(i2c)); i2c_pxa_start_message()
681 i2c->req_slave_addr = i2c_pxa_addr_byte(i2c->msg); i2c_pxa_start_message()
686 icr = readl(_ICR(i2c)) & ~(ICR_STOP | ICR_ALDIE); i2c_pxa_start_message()
687 writel(icr | ICR_START | ICR_TB, _ICR(i2c)); i2c_pxa_start_message()
690 static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c) i2c_pxa_stop_message() argument
697 icr = readl(_ICR(i2c)); i2c_pxa_stop_message()
699 writel(icr, _ICR(i2c)); i2c_pxa_stop_message()
702 static int i2c_pxa_pio_set_master(struct pxa_i2c *i2c) i2c_pxa_pio_set_master() argument
710 while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) { i2c_pxa_pio_set_master()
712 show_state(i2c); i2c_pxa_pio_set_master()
716 show_state(i2c); i2c_pxa_pio_set_master()
717 dev_err(&i2c->adap.dev, i2c_pxa_pio_set_master()
725 writel(readl(_ICR(i2c)) | ICR_SCLE, _ICR(i2c)); i2c_pxa_pio_set_master()
736 static int i2c_pxa_send_mastercode(struct pxa_i2c *i2c) i2c_pxa_send_mastercode() argument
741 spin_lock_irq(&i2c->lock); i2c_pxa_send_mastercode()
742 i2c->highmode_enter = true; i2c_pxa_send_mastercode()
743 writel(i2c->master_code, _IDBR(i2c)); i2c_pxa_send_mastercode()
745 icr = readl(_ICR(i2c)) & ~(ICR_STOP | ICR_ALDIE); i2c_pxa_send_mastercode()
747 writel(icr, _ICR(i2c)); i2c_pxa_send_mastercode()
749 spin_unlock_irq(&i2c->lock); i2c_pxa_send_mastercode()
750 timeout = wait_event_timeout(i2c->wait, i2c_pxa_send_mastercode()
751 i2c->highmode_enter == false, HZ * 1); i2c_pxa_send_mastercode()
753 i2c->highmode_enter = false; i2c_pxa_send_mastercode()
758 static int i2c_pxa_do_pio_xfer(struct pxa_i2c *i2c, i2c_pxa_do_pio_xfer() argument
764 ret = i2c_pxa_pio_set_master(i2c); i2c_pxa_do_pio_xfer()
768 i2c->msg = msg; i2c_pxa_do_pio_xfer()
769 i2c->msg_num = num; i2c_pxa_do_pio_xfer()
770 i2c->msg_idx = 0; i2c_pxa_do_pio_xfer()
771 i2c->msg_ptr = 0; i2c_pxa_do_pio_xfer()
772 i2c->irqlogidx = 0; i2c_pxa_do_pio_xfer()
774 i2c_pxa_start_message(i2c); i2c_pxa_do_pio_xfer()
776 while (i2c->msg_num > 0 && --timeout) { i2c_pxa_do_pio_xfer()
777 i2c_pxa_handler(0, i2c); i2c_pxa_do_pio_xfer()
781 i2c_pxa_stop_message(i2c); i2c_pxa_do_pio_xfer()
784 * We place the return code in i2c->msg_idx. i2c_pxa_do_pio_xfer()
786 ret = i2c->msg_idx; i2c_pxa_do_pio_xfer()
790 i2c_pxa_scream_blue_murder(i2c, "timeout"); i2c_pxa_do_pio_xfer()
800 static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num) i2c_pxa_do_xfer() argument
808 ret = i2c_pxa_wait_bus_not_busy(i2c); i2c_pxa_do_xfer()
810 dev_err(&i2c->adap.dev, "i2c_pxa: timeout waiting for bus free\n"); i2c_pxa_do_xfer()
817 ret = i2c_pxa_set_master(i2c); i2c_pxa_do_xfer()
819 dev_err(&i2c->adap.dev, "i2c_pxa_set_master: error %d\n", ret); i2c_pxa_do_xfer()
823 if (i2c->high_mode) { i2c_pxa_do_xfer()
824 ret = i2c_pxa_send_mastercode(i2c); i2c_pxa_do_xfer()
826 dev_err(&i2c->adap.dev, "i2c_pxa_send_mastercode timeout\n"); i2c_pxa_do_xfer()
831 spin_lock_irq(&i2c->lock); i2c_pxa_do_xfer()
833 i2c->msg = msg; i2c_pxa_do_xfer()
834 i2c->msg_num = num; i2c_pxa_do_xfer()
835 i2c->msg_idx = 0; i2c_pxa_do_xfer()
836 i2c->msg_ptr = 0; i2c_pxa_do_xfer()
837 i2c->irqlogidx = 0; i2c_pxa_do_xfer()
839 i2c_pxa_start_message(i2c); i2c_pxa_do_xfer()
841 spin_unlock_irq(&i2c->lock); i2c_pxa_do_xfer()
846 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); i2c_pxa_do_xfer()
847 i2c_pxa_stop_message(i2c); i2c_pxa_do_xfer()
850 * We place the return code in i2c->msg_idx. i2c_pxa_do_xfer()
852 ret = i2c->msg_idx; i2c_pxa_do_xfer()
854 if (!timeout && i2c->msg_num) { i2c_pxa_do_xfer()
855 i2c_pxa_scream_blue_murder(i2c, "timeout"); i2c_pxa_do_xfer()
866 struct pxa_i2c *i2c = adap->algo_data; i2c_pxa_pio_xfer() local
873 if (!(readl(_ICR(i2c)) & ICR_IUE)) i2c_pxa_pio_xfer()
874 i2c_pxa_reset(i2c); i2c_pxa_pio_xfer()
877 ret = i2c_pxa_do_pio_xfer(i2c, msgs, num); i2c_pxa_pio_xfer()
885 i2c_pxa_scream_blue_murder(i2c, "exhausted retries"); i2c_pxa_pio_xfer()
888 i2c_pxa_set_slave(i2c, ret); i2c_pxa_pio_xfer()
895 static void i2c_pxa_master_complete(struct pxa_i2c *i2c, int ret) i2c_pxa_master_complete() argument
897 i2c->msg_ptr = 0; i2c_pxa_master_complete()
898 i2c->msg = NULL; i2c_pxa_master_complete()
899 i2c->msg_idx ++; i2c_pxa_master_complete()
900 i2c->msg_num = 0; i2c_pxa_master_complete()
902 i2c->msg_idx = ret; i2c_pxa_master_complete()
903 if (!i2c->use_pio) i2c_pxa_master_complete()
904 wake_up(&i2c->wait); i2c_pxa_master_complete()
907 static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr) i2c_pxa_irq_txempty() argument
909 u32 icr = readl(_ICR(i2c)) & ~(ICR_START|ICR_STOP|ICR_ACKNAK|ICR_TB); i2c_pxa_irq_txempty()
920 i2c_pxa_scream_blue_murder(i2c, "ALD set"); i2c_pxa_irq_txempty()
932 (!((i2c->msg->flags & I2C_M_IGNORE_NAK) && i2c_pxa_irq_txempty()
942 if (i2c->msg_ptr == 0 && i2c->msg_idx == 0) i2c_pxa_irq_txempty()
947 i2c_pxa_master_complete(i2c, ret); i2c_pxa_irq_txempty()
953 if (i2c->msg_ptr == i2c->msg->len - 1 && i2c_pxa_irq_txempty()
954 i2c->msg_idx == i2c->msg_num - 1) i2c_pxa_irq_txempty()
958 } else if (i2c->msg_ptr < i2c->msg->len) { i2c_pxa_irq_txempty()
962 writel(i2c->msg->buf[i2c->msg_ptr++], _IDBR(i2c)); i2c_pxa_irq_txempty()
970 if ((i2c->msg_ptr == i2c->msg->len) && i2c_pxa_irq_txempty()
971 ((i2c->msg->flags & I2C_M_STOP) || i2c_pxa_irq_txempty()
972 (i2c->msg_idx == i2c->msg_num - 1))) i2c_pxa_irq_txempty()
975 } else if (i2c->msg_idx < i2c->msg_num - 1) { i2c_pxa_irq_txempty()
979 i2c->msg_ptr = 0; i2c_pxa_irq_txempty()
980 i2c->msg_idx ++; i2c_pxa_irq_txempty()
981 i2c->msg++; i2c_pxa_irq_txempty()
988 if (i2c->msg->flags & I2C_M_NOSTART) i2c_pxa_irq_txempty()
994 writel(i2c_pxa_addr_byte(i2c->msg), _IDBR(i2c)); i2c_pxa_irq_txempty()
995 i2c->req_slave_addr = i2c_pxa_addr_byte(i2c->msg); i2c_pxa_irq_txempty()
1003 if (i2c->msg->len == 0) { i2c_pxa_irq_txempty()
1009 i2c_pxa_reset(i2c); i2c_pxa_irq_txempty()
1011 i2c_pxa_master_complete(i2c, 0); i2c_pxa_irq_txempty()
1014 i2c->icrlog[i2c->irqlogidx-1] = icr; i2c_pxa_irq_txempty()
1016 writel(icr, _ICR(i2c)); i2c_pxa_irq_txempty()
1017 show_state(i2c); i2c_pxa_irq_txempty()
1020 static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr) i2c_pxa_irq_rxfull() argument
1022 u32 icr = readl(_ICR(i2c)) & ~(ICR_START|ICR_STOP|ICR_ACKNAK|ICR_TB); i2c_pxa_irq_rxfull()
1027 i2c->msg->buf[i2c->msg_ptr++] = readl(_IDBR(i2c)); i2c_pxa_irq_rxfull()
1029 if (i2c->msg_ptr < i2c->msg->len) { i2c_pxa_irq_rxfull()
1034 if (i2c->msg_ptr == i2c->msg->len - 1) i2c_pxa_irq_rxfull()
1039 i2c_pxa_master_complete(i2c, 0); i2c_pxa_irq_rxfull()
1042 i2c->icrlog[i2c->irqlogidx-1] = icr; i2c_pxa_irq_rxfull()
1044 writel(icr, _ICR(i2c)); i2c_pxa_irq_rxfull()
1051 struct pxa_i2c *i2c = dev_id; i2c_pxa_handler() local
1052 u32 isr = readl(_ISR(i2c)); i2c_pxa_handler()
1058 dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n", i2c_pxa_handler()
1059 __func__, isr, readl(_ICR(i2c)), readl(_IBMR(i2c))); i2c_pxa_handler()
1063 if (i2c->irqlogidx < ARRAY_SIZE(i2c->isrlog)) i2c_pxa_handler()
1064 i2c->isrlog[i2c->irqlogidx++] = isr; i2c_pxa_handler()
1066 show_state(i2c); i2c_pxa_handler()
1071 writel(isr & VALID_INT_SOURCE, _ISR(i2c)); i2c_pxa_handler()
1074 i2c_pxa_slave_start(i2c, isr); i2c_pxa_handler()
1076 i2c_pxa_slave_stop(i2c); i2c_pxa_handler()
1078 if (i2c_pxa_is_slavemode(i2c)) { i2c_pxa_handler()
1080 i2c_pxa_slave_txempty(i2c, isr); i2c_pxa_handler()
1082 i2c_pxa_slave_rxfull(i2c, isr); i2c_pxa_handler()
1083 } else if (i2c->msg && (!i2c->highmode_enter)) { i2c_pxa_handler()
1085 i2c_pxa_irq_txempty(i2c, isr); i2c_pxa_handler()
1087 i2c_pxa_irq_rxfull(i2c, isr); i2c_pxa_handler()
1088 } else if ((isr & ISR_ITE) && i2c->highmode_enter) { i2c_pxa_handler()
1089 i2c->highmode_enter = false; i2c_pxa_handler()
1090 wake_up(&i2c->wait); i2c_pxa_handler()
1092 i2c_pxa_scream_blue_murder(i2c, "spurious irq"); i2c_pxa_handler()
1101 struct pxa_i2c *i2c = adap->algo_data; i2c_pxa_xfer() local
1105 ret = i2c_pxa_do_xfer(i2c, msgs, num); i2c_pxa_xfer()
1113 i2c_pxa_scream_blue_murder(i2c, "exhausted retries"); i2c_pxa_xfer()
1116 i2c_pxa_set_slave(i2c, ret); i2c_pxa_xfer()
1137 { .compatible = "mrvl,pxa-i2c", .data = (void *)REGS_PXA2XX },
1144 static int i2c_pxa_probe_dt(struct platform_device *pdev, struct pxa_i2c *i2c, i2c_pxa_probe_dt() argument
1155 i2c->adap.nr = -1; i2c_pxa_probe_dt()
1157 if (of_get_property(np, "mrvl,i2c-polling", NULL)) i2c_pxa_probe_dt()
1158 i2c->use_pio = 1; i2c_pxa_probe_dt()
1159 if (of_get_property(np, "mrvl,i2c-fast-mode", NULL)) i2c_pxa_probe_dt()
1160 i2c->fast_mode = 1; i2c_pxa_probe_dt()
1168 struct pxa_i2c *i2c, i2c_pxa_probe_pdata()
1176 i2c->use_pio = plat->use_pio; i2c_pxa_probe_pdata()
1177 i2c->fast_mode = plat->fast_mode; i2c_pxa_probe_pdata()
1178 i2c->high_mode = plat->high_mode; i2c_pxa_probe_pdata()
1179 i2c->master_code = plat->master_code; i2c_pxa_probe_pdata()
1180 if (!i2c->master_code) i2c_pxa_probe_pdata()
1181 i2c->master_code = 0xe; i2c_pxa_probe_pdata()
1182 i2c->rate = plat->rate; i2c_pxa_probe_pdata()
1191 struct pxa_i2c *i2c; i2c_pxa_probe() local
1195 i2c = devm_kzalloc(&dev->dev, sizeof(struct pxa_i2c), GFP_KERNEL); i2c_pxa_probe()
1196 if (!i2c) i2c_pxa_probe()
1200 i2c->reg_base = devm_ioremap_resource(&dev->dev, res); i2c_pxa_probe()
1201 if (IS_ERR(i2c->reg_base)) i2c_pxa_probe()
1202 return PTR_ERR(i2c->reg_base); i2c_pxa_probe()
1211 i2c->adap.nr = dev->id; i2c_pxa_probe()
1213 ret = i2c_pxa_probe_dt(dev, i2c, &i2c_type); i2c_pxa_probe()
1215 ret = i2c_pxa_probe_pdata(dev, i2c, &i2c_type); i2c_pxa_probe()
1219 i2c->adap.owner = THIS_MODULE; i2c_pxa_probe()
1220 i2c->adap.retries = 5; i2c_pxa_probe()
1222 spin_lock_init(&i2c->lock); i2c_pxa_probe()
1223 init_waitqueue_head(&i2c->wait); i2c_pxa_probe()
1225 strlcpy(i2c->adap.name, "pxa_i2c-i2c", sizeof(i2c->adap.name)); i2c_pxa_probe()
1227 i2c->clk = devm_clk_get(&dev->dev, NULL); i2c_pxa_probe()
1228 if (IS_ERR(i2c->clk)) { i2c_pxa_probe()
1229 dev_err(&dev->dev, "failed to get the clk: %ld\n", PTR_ERR(i2c->clk)); i2c_pxa_probe()
1230 return PTR_ERR(i2c->clk); i2c_pxa_probe()
1233 i2c->reg_ibmr = i2c->reg_base + pxa_reg_layout[i2c_type].ibmr; i2c_pxa_probe()
1234 i2c->reg_idbr = i2c->reg_base + pxa_reg_layout[i2c_type].idbr; i2c_pxa_probe()
1235 i2c->reg_icr = i2c->reg_base + pxa_reg_layout[i2c_type].icr; i2c_pxa_probe()
1236 i2c->reg_isr = i2c->reg_base + pxa_reg_layout[i2c_type].isr; i2c_pxa_probe()
1238 i2c->reg_isar = i2c->reg_base + pxa_reg_layout[i2c_type].isar; i2c_pxa_probe()
1241 i2c->reg_ilcr = i2c->reg_base + pxa_reg_layout[i2c_type].ilcr; i2c_pxa_probe()
1242 i2c->reg_iwcr = i2c->reg_base + pxa_reg_layout[i2c_type].iwcr; i2c_pxa_probe()
1245 i2c->iobase = res->start; i2c_pxa_probe()
1246 i2c->iosize = resource_size(res); i2c_pxa_probe()
1248 i2c->irq = irq; i2c_pxa_probe()
1250 i2c->slave_addr = I2C_PXA_SLAVE_ADDR; i2c_pxa_probe()
1251 i2c->highmode_enter = false; i2c_pxa_probe()
1255 i2c->slave_addr = plat->slave_addr; i2c_pxa_probe()
1256 i2c->slave = plat->slave; i2c_pxa_probe()
1258 i2c->adap.class = plat->class; i2c_pxa_probe()
1261 if (i2c->high_mode) { i2c_pxa_probe()
1262 if (i2c->rate) { i2c_pxa_probe()
1263 clk_set_rate(i2c->clk, i2c->rate); i2c_pxa_probe()
1264 pr_info("i2c: <%s> set rate to %ld\n", i2c_pxa_probe()
1265 i2c->adap.name, clk_get_rate(i2c->clk)); i2c_pxa_probe()
1267 pr_warn("i2c: <%s> clock rate not set\n", i2c_pxa_probe()
1268 i2c->adap.name); i2c_pxa_probe()
1271 clk_prepare_enable(i2c->clk); i2c_pxa_probe()
1273 if (i2c->use_pio) { i2c_pxa_probe()
1274 i2c->adap.algo = &i2c_pxa_pio_algorithm; i2c_pxa_probe()
1276 i2c->adap.algo = &i2c_pxa_algorithm; i2c_pxa_probe()
1279 dev_name(&dev->dev), i2c); i2c_pxa_probe()
1286 i2c_pxa_reset(i2c); i2c_pxa_probe()
1288 i2c->adap.algo_data = i2c; i2c_pxa_probe()
1289 i2c->adap.dev.parent = &dev->dev; i2c_pxa_probe()
1291 i2c->adap.dev.of_node = dev->dev.of_node; i2c_pxa_probe()
1294 ret = i2c_add_numbered_adapter(&i2c->adap); i2c_pxa_probe()
1300 platform_set_drvdata(dev, i2c); i2c_pxa_probe()
1303 dev_info(&i2c->adap.dev, " PXA I2C adapter, slave address %d\n", i2c_pxa_probe()
1304 i2c->slave_addr); i2c_pxa_probe()
1306 dev_info(&i2c->adap.dev, " PXA I2C adapter\n"); i2c_pxa_probe()
1311 clk_disable_unprepare(i2c->clk); i2c_pxa_probe()
1317 struct pxa_i2c *i2c = platform_get_drvdata(dev); i2c_pxa_remove() local
1319 i2c_del_adapter(&i2c->adap); i2c_pxa_remove()
1321 clk_disable_unprepare(i2c->clk); i2c_pxa_remove()
1330 struct pxa_i2c *i2c = platform_get_drvdata(pdev); i2c_pxa_suspend_noirq() local
1332 clk_disable(i2c->clk); i2c_pxa_suspend_noirq()
1340 struct pxa_i2c *i2c = platform_get_drvdata(pdev); i2c_pxa_resume_noirq() local
1342 clk_enable(i2c->clk); i2c_pxa_resume_noirq()
1343 i2c_pxa_reset(i2c); i2c_pxa_resume_noirq()
1362 .name = "pxa2xx-i2c",
1380 MODULE_ALIAS("platform:pxa2xx-i2c");
1167 i2c_pxa_probe_pdata(struct platform_device *pdev, struct pxa_i2c *i2c, enum pxa_i2c_types *i2c_types) i2c_pxa_probe_pdata() argument
H A Di2c-ocores.c2 * i2c-ocores.c: I2C bus driver for OpenCores I2C controller
3 * (http://www.opencores.org/projects.cgi/web/i2c/overview).
21 #include <linux/i2c.h>
24 #include <linux/i2c-ocores.h>
42 void (*setreg)(struct ocores_i2c *i2c, int reg, u8 value);
43 u8 (*getreg)(struct ocores_i2c *i2c, int reg);
80 static void oc_setreg_8(struct ocores_i2c *i2c, int reg, u8 value) oc_setreg_8() argument
82 iowrite8(value, i2c->base + (reg << i2c->reg_shift)); oc_setreg_8()
85 static void oc_setreg_16(struct ocores_i2c *i2c, int reg, u8 value) oc_setreg_16() argument
87 iowrite16(value, i2c->base + (reg << i2c->reg_shift)); oc_setreg_16()
90 static void oc_setreg_32(struct ocores_i2c *i2c, int reg, u8 value) oc_setreg_32() argument
92 iowrite32(value, i2c->base + (reg << i2c->reg_shift)); oc_setreg_32()
95 static void oc_setreg_16be(struct ocores_i2c *i2c, int reg, u8 value) oc_setreg_16be() argument
97 iowrite16be(value, i2c->base + (reg << i2c->reg_shift)); oc_setreg_16be()
100 static void oc_setreg_32be(struct ocores_i2c *i2c, int reg, u8 value) oc_setreg_32be() argument
102 iowrite32be(value, i2c->base + (reg << i2c->reg_shift)); oc_setreg_32be()
105 static inline u8 oc_getreg_8(struct ocores_i2c *i2c, int reg) oc_getreg_8() argument
107 return ioread8(i2c->base + (reg << i2c->reg_shift)); oc_getreg_8()
110 static inline u8 oc_getreg_16(struct ocores_i2c *i2c, int reg) oc_getreg_16() argument
112 return ioread16(i2c->base + (reg << i2c->reg_shift)); oc_getreg_16()
115 static inline u8 oc_getreg_32(struct ocores_i2c *i2c, int reg) oc_getreg_32() argument
117 return ioread32(i2c->base + (reg << i2c->reg_shift)); oc_getreg_32()
120 static inline u8 oc_getreg_16be(struct ocores_i2c *i2c, int reg) oc_getreg_16be() argument
122 return ioread16be(i2c->base + (reg << i2c->reg_shift)); oc_getreg_16be()
125 static inline u8 oc_getreg_32be(struct ocores_i2c *i2c, int reg) oc_getreg_32be() argument
127 return ioread32be(i2c->base + (reg << i2c->reg_shift)); oc_getreg_32be()
130 static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) oc_setreg() argument
132 i2c->setreg(i2c, reg, value); oc_setreg()
135 static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg) oc_getreg() argument
137 return i2c->getreg(i2c, reg); oc_getreg()
140 static void ocores_process(struct ocores_i2c *i2c) ocores_process() argument
142 struct i2c_msg *msg = i2c->msg; ocores_process()
143 u8 stat = oc_getreg(i2c, OCI2C_STATUS); ocores_process()
145 if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) { ocores_process()
147 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK); ocores_process()
148 wake_up(&i2c->wait); ocores_process()
154 i2c->state = STATE_ERROR; ocores_process()
155 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); ocores_process()
159 if ((i2c->state == STATE_START) || (i2c->state == STATE_WRITE)) { ocores_process()
160 i2c->state = ocores_process()
164 i2c->state = STATE_ERROR; ocores_process()
165 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); ocores_process()
169 msg->buf[i2c->pos++] = oc_getreg(i2c, OCI2C_DATA); ocores_process()
172 if (i2c->pos == msg->len) { ocores_process()
173 i2c->nmsgs--; ocores_process()
174 i2c->msg++; ocores_process()
175 i2c->pos = 0; ocores_process()
176 msg = i2c->msg; ocores_process()
178 if (i2c->nmsgs) { /* end? */ ocores_process()
186 i2c->state = STATE_START; ocores_process()
188 oc_setreg(i2c, OCI2C_DATA, addr); ocores_process()
189 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START); ocores_process()
192 i2c->state = (msg->flags & I2C_M_RD) ocores_process()
195 i2c->state = STATE_DONE; ocores_process()
196 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); ocores_process()
201 if (i2c->state == STATE_READ) { ocores_process()
202 oc_setreg(i2c, OCI2C_CMD, i2c->pos == (msg->len-1) ? ocores_process()
205 oc_setreg(i2c, OCI2C_DATA, msg->buf[i2c->pos++]); ocores_process()
206 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_WRITE); ocores_process()
212 struct ocores_i2c *i2c = dev_id; ocores_isr() local
214 ocores_process(i2c); ocores_isr()
221 struct ocores_i2c *i2c = i2c_get_adapdata(adap); ocores_xfer() local
223 i2c->msg = msgs; ocores_xfer()
224 i2c->pos = 0; ocores_xfer()
225 i2c->nmsgs = num; ocores_xfer()
226 i2c->state = STATE_START; ocores_xfer()
228 oc_setreg(i2c, OCI2C_DATA, ocores_xfer()
229 (i2c->msg->addr << 1) | ocores_xfer()
230 ((i2c->msg->flags & I2C_M_RD) ? 1:0)); ocores_xfer()
232 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START); ocores_xfer()
234 if (wait_event_timeout(i2c->wait, (i2c->state == STATE_ERROR) || ocores_xfer()
235 (i2c->state == STATE_DONE), HZ)) ocores_xfer()
236 return (i2c->state == STATE_DONE) ? num : -EIO; ocores_xfer()
241 static int ocores_init(struct device *dev, struct ocores_i2c *i2c) ocores_init() argument
245 u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); ocores_init()
248 oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~(OCI2C_CTRL_EN|OCI2C_CTRL_IEN)); ocores_init()
250 prescale = (i2c->ip_clock_khz / (5 * i2c->bus_clock_khz)) - 1; ocores_init()
253 diff = i2c->ip_clock_khz / (5 * (prescale + 1)) - i2c->bus_clock_khz; ocores_init()
254 if (abs(diff) > i2c->bus_clock_khz / 10) { ocores_init()
257 i2c->ip_clock_khz, i2c->bus_clock_khz); ocores_init()
261 oc_setreg(i2c, OCI2C_PRELOW, prescale & 0xff); ocores_init()
262 oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8); ocores_init()
265 oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK); ocores_init()
266 oc_setreg(i2c, OCI2C_CONTROL, ctrl | OCI2C_CTRL_IEN | OCI2C_CTRL_EN); ocores_init()
284 .name = "i2c-ocores",
291 .compatible = "opencores,i2c-ocores",
306 static u8 oc_getreg_grlib(struct ocores_i2c *i2c, int reg) oc_getreg_grlib() argument
312 rd = ioread32be(i2c->base + (rreg << i2c->reg_shift)); oc_getreg_grlib()
319 static void oc_setreg_grlib(struct ocores_i2c *i2c, int reg, u8 value) oc_setreg_grlib() argument
326 curr = ioread32be(i2c->base + (rreg << i2c->reg_shift)); oc_setreg_grlib()
334 iowrite32be(wr, i2c->base + (rreg << i2c->reg_shift)); oc_setreg_grlib()
338 struct ocores_i2c *i2c) ocores_i2c_of_probe()
346 if (of_property_read_u32(np, "reg-shift", &i2c->reg_shift)) { ocores_i2c_of_probe()
354 i2c->reg_shift = ilog2(val); ocores_i2c_of_probe()
362 i2c->bus_clock_khz = 100; ocores_i2c_of_probe()
364 i2c->clk = devm_clk_get(&pdev->dev, NULL); ocores_i2c_of_probe()
366 if (!IS_ERR(i2c->clk)) { ocores_i2c_of_probe()
367 int ret = clk_prepare_enable(i2c->clk); ocores_i2c_of_probe()
374 i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000; ocores_i2c_of_probe()
376 i2c->bus_clock_khz = clock_frequency / 1000; ocores_i2c_of_probe()
379 if (i2c->ip_clock_khz == 0) { ocores_i2c_of_probe()
387 i2c->ip_clock_khz = clock_frequency / 1000; ocores_i2c_of_probe()
391 i2c->ip_clock_khz = val / 1000; ocores_i2c_of_probe()
393 i2c->bus_clock_khz = clock_frequency / 1000; ocores_i2c_of_probe()
398 &i2c->reg_io_width); ocores_i2c_of_probe()
402 dev_dbg(&pdev->dev, "GRLIB variant of i2c-ocores\n"); ocores_i2c_of_probe()
403 i2c->setreg = oc_setreg_grlib; ocores_i2c_of_probe()
404 i2c->getreg = oc_getreg_grlib; ocores_i2c_of_probe()
410 #define ocores_i2c_of_probe(pdev,i2c) -ENODEV
415 struct ocores_i2c *i2c; ocores_i2c_probe() local
426 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); ocores_i2c_probe()
427 if (!i2c) ocores_i2c_probe()
431 i2c->base = devm_ioremap_resource(&pdev->dev, res); ocores_i2c_probe()
432 if (IS_ERR(i2c->base)) ocores_i2c_probe()
433 return PTR_ERR(i2c->base); ocores_i2c_probe()
437 i2c->reg_shift = pdata->reg_shift; ocores_i2c_probe()
438 i2c->reg_io_width = pdata->reg_io_width; ocores_i2c_probe()
439 i2c->ip_clock_khz = pdata->clock_khz; ocores_i2c_probe()
440 i2c->bus_clock_khz = 100; ocores_i2c_probe()
442 ret = ocores_i2c_of_probe(pdev, i2c); ocores_i2c_probe()
447 if (i2c->reg_io_width == 0) ocores_i2c_probe()
448 i2c->reg_io_width = 1; /* Set to default value */ ocores_i2c_probe()
450 if (!i2c->setreg || !i2c->getreg) { ocores_i2c_probe()
454 switch (i2c->reg_io_width) { ocores_i2c_probe()
456 i2c->setreg = oc_setreg_8; ocores_i2c_probe()
457 i2c->getreg = oc_getreg_8; ocores_i2c_probe()
461 i2c->setreg = be ? oc_setreg_16be : oc_setreg_16; ocores_i2c_probe()
462 i2c->getreg = be ? oc_getreg_16be : oc_getreg_16; ocores_i2c_probe()
466 i2c->setreg = be ? oc_setreg_32be : oc_setreg_32; ocores_i2c_probe()
467 i2c->getreg = be ? oc_getreg_32be : oc_getreg_32; ocores_i2c_probe()
472 i2c->reg_io_width); ocores_i2c_probe()
477 ret = ocores_init(&pdev->dev, i2c); ocores_i2c_probe()
481 init_waitqueue_head(&i2c->wait); ocores_i2c_probe()
483 pdev->name, i2c); ocores_i2c_probe()
490 platform_set_drvdata(pdev, i2c); ocores_i2c_probe()
491 i2c->adap = ocores_adapter; ocores_i2c_probe()
492 i2c_set_adapdata(&i2c->adap, i2c); ocores_i2c_probe()
493 i2c->adap.dev.parent = &pdev->dev; ocores_i2c_probe()
494 i2c->adap.dev.of_node = pdev->dev.of_node; ocores_i2c_probe()
496 /* add i2c adapter to i2c tree */ ocores_i2c_probe()
497 ret = i2c_add_adapter(&i2c->adap); ocores_i2c_probe()
506 i2c_new_device(&i2c->adap, pdata->devices + i); ocores_i2c_probe()
514 struct ocores_i2c *i2c = platform_get_drvdata(pdev); ocores_i2c_remove() local
516 /* disable i2c logic */ ocores_i2c_remove()
517 oc_setreg(i2c, OCI2C_CONTROL, oc_getreg(i2c, OCI2C_CONTROL) ocores_i2c_remove()
521 i2c_del_adapter(&i2c->adap); ocores_i2c_remove()
523 if (!IS_ERR(i2c->clk)) ocores_i2c_remove()
524 clk_disable_unprepare(i2c->clk); ocores_i2c_remove()
532 struct ocores_i2c *i2c = dev_get_drvdata(dev); ocores_i2c_suspend() local
533 u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); ocores_i2c_suspend()
536 oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~(OCI2C_CTRL_EN|OCI2C_CTRL_IEN)); ocores_i2c_suspend()
538 if (!IS_ERR(i2c->clk)) ocores_i2c_suspend()
539 clk_disable_unprepare(i2c->clk); ocores_i2c_suspend()
545 struct ocores_i2c *i2c = dev_get_drvdata(dev); ocores_i2c_resume() local
547 if (!IS_ERR(i2c->clk)) { ocores_i2c_resume()
549 int ret = clk_prepare_enable(i2c->clk); ocores_i2c_resume()
556 rate = clk_get_rate(i2c->clk) / 1000; ocores_i2c_resume()
558 i2c->ip_clock_khz = rate; ocores_i2c_resume()
560 return ocores_init(dev, i2c); ocores_i2c_resume()
573 .name = "ocores-i2c",
584 MODULE_ALIAS("platform:ocores-i2c");
337 ocores_i2c_of_probe(struct platform_device *pdev, struct ocores_i2c *i2c) ocores_i2c_of_probe() argument
H A Di2c-xiic.c2 * i2c-xiic.c
33 #include <linux/i2c.h>
36 #include <linux/i2c-xiic.h>
41 #define DRIVER_NAME "xiic-i2c"
174 #define xiic_tx_space(i2c) ((i2c)->tx_msg->len - (i2c)->tx_pos)
175 #define xiic_rx_space(i2c) ((i2c)->rx_msg->len - (i2c)->rx_pos)
177 static void xiic_start_xfer(struct xiic_i2c *i2c);
178 static void __xiic_start_xfer(struct xiic_i2c *i2c);
188 static inline void xiic_setreg8(struct xiic_i2c *i2c, int reg, u8 value) xiic_setreg8() argument
190 if (i2c->endianness == LITTLE) xiic_setreg8()
191 iowrite8(value, i2c->base + reg); xiic_setreg8()
193 iowrite8(value, i2c->base + reg + 3); xiic_setreg8()
196 static inline u8 xiic_getreg8(struct xiic_i2c *i2c, int reg) xiic_getreg8() argument
200 if (i2c->endianness == LITTLE) xiic_getreg8()
201 ret = ioread8(i2c->base + reg); xiic_getreg8()
203 ret = ioread8(i2c->base + reg + 3); xiic_getreg8()
207 static inline void xiic_setreg16(struct xiic_i2c *i2c, int reg, u16 value) xiic_setreg16() argument
209 if (i2c->endianness == LITTLE) xiic_setreg16()
210 iowrite16(value, i2c->base + reg); xiic_setreg16()
212 iowrite16be(value, i2c->base + reg + 2); xiic_setreg16()
215 static inline void xiic_setreg32(struct xiic_i2c *i2c, int reg, int value) xiic_setreg32() argument
217 if (i2c->endianness == LITTLE) xiic_setreg32()
218 iowrite32(value, i2c->base + reg); xiic_setreg32()
220 iowrite32be(value, i2c->base + reg); xiic_setreg32()
223 static inline int xiic_getreg32(struct xiic_i2c *i2c, int reg) xiic_getreg32() argument
227 if (i2c->endianness == LITTLE) xiic_getreg32()
228 ret = ioread32(i2c->base + reg); xiic_getreg32()
230 ret = ioread32be(i2c->base + reg); xiic_getreg32()
234 static inline void xiic_irq_dis(struct xiic_i2c *i2c, u32 mask) xiic_irq_dis() argument
236 u32 ier = xiic_getreg32(i2c, XIIC_IIER_OFFSET); xiic_irq_dis()
237 xiic_setreg32(i2c, XIIC_IIER_OFFSET, ier & ~mask); xiic_irq_dis()
240 static inline void xiic_irq_en(struct xiic_i2c *i2c, u32 mask) xiic_irq_en() argument
242 u32 ier = xiic_getreg32(i2c, XIIC_IIER_OFFSET); xiic_irq_en()
243 xiic_setreg32(i2c, XIIC_IIER_OFFSET, ier | mask); xiic_irq_en()
246 static inline void xiic_irq_clr(struct xiic_i2c *i2c, u32 mask) xiic_irq_clr() argument
248 u32 isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET); xiic_irq_clr()
249 xiic_setreg32(i2c, XIIC_IISR_OFFSET, isr & mask); xiic_irq_clr()
252 static inline void xiic_irq_clr_en(struct xiic_i2c *i2c, u32 mask) xiic_irq_clr_en() argument
254 xiic_irq_clr(i2c, mask); xiic_irq_clr_en()
255 xiic_irq_en(i2c, mask); xiic_irq_clr_en()
258 static void xiic_clear_rx_fifo(struct xiic_i2c *i2c) xiic_clear_rx_fifo() argument
261 for (sr = xiic_getreg8(i2c, XIIC_SR_REG_OFFSET); xiic_clear_rx_fifo()
263 sr = xiic_getreg8(i2c, XIIC_SR_REG_OFFSET)) xiic_clear_rx_fifo()
264 xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET); xiic_clear_rx_fifo()
267 static void xiic_reinit(struct xiic_i2c *i2c) xiic_reinit() argument
269 xiic_setreg32(i2c, XIIC_RESETR_OFFSET, XIIC_RESET_MASK); xiic_reinit()
272 xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, IIC_RX_FIFO_DEPTH - 1); xiic_reinit()
275 xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, XIIC_CR_TX_FIFO_RESET_MASK); xiic_reinit()
278 xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, XIIC_CR_ENABLE_DEVICE_MASK); xiic_reinit()
281 xiic_clear_rx_fifo(i2c); xiic_reinit()
284 xiic_setreg32(i2c, XIIC_DGIER_OFFSET, XIIC_GINTR_ENABLE_MASK); xiic_reinit()
286 xiic_irq_clr_en(i2c, XIIC_INTR_ARB_LOST_MASK); xiic_reinit()
289 static void xiic_deinit(struct xiic_i2c *i2c) xiic_deinit() argument
293 xiic_setreg32(i2c, XIIC_RESETR_OFFSET, XIIC_RESET_MASK); xiic_deinit()
296 cr = xiic_getreg8(i2c, XIIC_CR_REG_OFFSET); xiic_deinit()
297 xiic_setreg8(i2c, XIIC_CR_REG_OFFSET, cr & ~XIIC_CR_ENABLE_DEVICE_MASK); xiic_deinit()
300 static void xiic_read_rx(struct xiic_i2c *i2c) xiic_read_rx() argument
305 bytes_in_fifo = xiic_getreg8(i2c, XIIC_RFO_REG_OFFSET) + 1; xiic_read_rx()
307 dev_dbg(i2c->adap.dev.parent, xiic_read_rx()
309 __func__, bytes_in_fifo, xiic_rx_space(i2c), xiic_read_rx()
310 xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), xiic_read_rx()
311 xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); xiic_read_rx()
313 if (bytes_in_fifo > xiic_rx_space(i2c)) xiic_read_rx()
314 bytes_in_fifo = xiic_rx_space(i2c); xiic_read_rx()
317 i2c->rx_msg->buf[i2c->rx_pos++] = xiic_read_rx()
318 xiic_getreg8(i2c, XIIC_DRR_REG_OFFSET); xiic_read_rx()
320 xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, xiic_read_rx()
321 (xiic_rx_space(i2c) > IIC_RX_FIFO_DEPTH) ? xiic_read_rx()
322 IIC_RX_FIFO_DEPTH - 1 : xiic_rx_space(i2c) - 1); xiic_read_rx()
325 static int xiic_tx_fifo_space(struct xiic_i2c *i2c) xiic_tx_fifo_space() argument
328 return IIC_TX_FIFO_DEPTH - xiic_getreg8(i2c, XIIC_TFO_REG_OFFSET) - 1; xiic_tx_fifo_space()
331 static void xiic_fill_tx_fifo(struct xiic_i2c *i2c) xiic_fill_tx_fifo() argument
333 u8 fifo_space = xiic_tx_fifo_space(i2c); xiic_fill_tx_fifo()
334 int len = xiic_tx_space(i2c); xiic_fill_tx_fifo()
338 dev_dbg(i2c->adap.dev.parent, "%s entry, len: %d, fifo space: %d\n", xiic_fill_tx_fifo()
342 u16 data = i2c->tx_msg->buf[i2c->tx_pos++]; xiic_fill_tx_fifo()
343 if ((xiic_tx_space(i2c) == 0) && (i2c->nmsgs == 1)) { xiic_fill_tx_fifo()
346 dev_dbg(i2c->adap.dev.parent, "%s TX STOP\n", __func__); xiic_fill_tx_fifo()
348 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); xiic_fill_tx_fifo()
352 static void xiic_wakeup(struct xiic_i2c *i2c, int code) xiic_wakeup() argument
354 i2c->tx_msg = NULL; xiic_wakeup()
355 i2c->rx_msg = NULL; xiic_wakeup()
356 i2c->nmsgs = 0; xiic_wakeup()
357 i2c->state = code; xiic_wakeup()
358 wake_up(&i2c->wait); xiic_wakeup()
363 struct xiic_i2c *i2c = dev_id; xiic_process() local
372 spin_lock(&i2c->lock); xiic_process()
373 isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET); xiic_process()
374 ier = xiic_getreg32(i2c, XIIC_IIER_OFFSET); xiic_process()
377 dev_dbg(i2c->adap.dev.parent, "%s: IER: 0x%x, ISR: 0x%x, pend: 0x%x\n", xiic_process()
379 dev_dbg(i2c->adap.dev.parent, "%s: SR: 0x%x, msg: %p, nmsgs: %d\n", xiic_process()
380 __func__, xiic_getreg8(i2c, XIIC_SR_REG_OFFSET), xiic_process()
381 i2c->tx_msg, i2c->nmsgs); xiic_process()
394 dev_dbg(i2c->adap.dev.parent, "%s error\n", __func__); xiic_process()
400 xiic_reinit(i2c); xiic_process()
402 if (i2c->rx_msg) xiic_process()
403 xiic_wakeup(i2c, STATE_ERROR); xiic_process()
404 if (i2c->tx_msg) xiic_process()
405 xiic_wakeup(i2c, STATE_ERROR); xiic_process()
411 if (!i2c->rx_msg) { xiic_process()
412 dev_dbg(i2c->adap.dev.parent, xiic_process()
414 xiic_clear_rx_fifo(i2c); xiic_process()
418 xiic_read_rx(i2c); xiic_process()
419 if (xiic_rx_space(i2c) == 0) { xiic_process()
421 i2c->rx_msg = NULL; xiic_process()
426 dev_dbg(i2c->adap.dev.parent, xiic_process()
428 __func__, i2c->nmsgs); xiic_process()
434 if (i2c->nmsgs > 1) { xiic_process()
435 i2c->nmsgs--; xiic_process()
436 i2c->tx_msg++; xiic_process()
437 dev_dbg(i2c->adap.dev.parent, xiic_process()
440 __xiic_start_xfer(i2c); xiic_process()
449 xiic_irq_dis(i2c, XIIC_INTR_BNB_MASK); xiic_process()
451 if (!i2c->tx_msg) xiic_process()
454 if ((i2c->nmsgs == 1) && !i2c->rx_msg && xiic_process()
455 xiic_tx_space(i2c) == 0) xiic_process()
456 xiic_wakeup(i2c, STATE_DONE); xiic_process()
458 xiic_wakeup(i2c, STATE_ERROR); xiic_process()
466 if (!i2c->tx_msg) { xiic_process()
467 dev_dbg(i2c->adap.dev.parent, xiic_process()
472 xiic_fill_tx_fifo(i2c); xiic_process()
475 if (!xiic_tx_space(i2c) && xiic_tx_fifo_space(i2c) >= 2) { xiic_process()
476 dev_dbg(i2c->adap.dev.parent, xiic_process()
478 __func__, i2c->nmsgs); xiic_process()
479 if (i2c->nmsgs > 1) { xiic_process()
480 i2c->nmsgs--; xiic_process()
481 i2c->tx_msg++; xiic_process()
482 __xiic_start_xfer(i2c); xiic_process()
484 xiic_irq_dis(i2c, XIIC_INTR_TX_HALF_MASK); xiic_process()
486 dev_dbg(i2c->adap.dev.parent, xiic_process()
490 } else if (!xiic_tx_space(i2c) && (i2c->nmsgs == 1)) xiic_process()
494 xiic_irq_dis(i2c, XIIC_INTR_TX_HALF_MASK); xiic_process()
497 dev_dbg(i2c->adap.dev.parent, "%s clr: 0x%x\n", __func__, clr); xiic_process()
499 xiic_setreg32(i2c, XIIC_IISR_OFFSET, clr); xiic_process()
500 spin_unlock(&i2c->lock); xiic_process()
504 static int xiic_bus_busy(struct xiic_i2c *i2c) xiic_bus_busy() argument
506 u8 sr = xiic_getreg8(i2c, XIIC_SR_REG_OFFSET); xiic_bus_busy()
511 static int xiic_busy(struct xiic_i2c *i2c) xiic_busy() argument
516 if (i2c->tx_msg) xiic_busy()
523 err = xiic_bus_busy(i2c); xiic_busy()
526 err = xiic_bus_busy(i2c); xiic_busy()
532 static void xiic_start_recv(struct xiic_i2c *i2c) xiic_start_recv() argument
535 struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; xiic_start_recv()
538 xiic_irq_clr_en(i2c, XIIC_INTR_RX_FULL_MASK | XIIC_INTR_TX_ERROR_MASK); xiic_start_recv()
549 xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rx_watermark - 1); xiic_start_recv()
553 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, xiic_start_recv()
557 xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); xiic_start_recv()
559 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, xiic_start_recv()
560 msg->len | ((i2c->nmsgs == 1) ? XIIC_TX_DYN_STOP_MASK : 0)); xiic_start_recv()
561 if (i2c->nmsgs == 1) xiic_start_recv()
563 xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK); xiic_start_recv()
566 i2c->tx_pos = msg->len; xiic_start_recv()
569 static void xiic_start_send(struct xiic_i2c *i2c) xiic_start_send() argument
571 struct i2c_msg *msg = i2c->tx_msg; xiic_start_send()
573 xiic_irq_clr(i2c, XIIC_INTR_TX_ERROR_MASK); xiic_start_send()
575 dev_dbg(i2c->adap.dev.parent, "%s entry, msg: %p, len: %d", xiic_start_send()
577 dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", xiic_start_send()
578 __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), xiic_start_send()
579 xiic_getreg8(i2c, XIIC_CR_REG_OFFSET)); xiic_start_send()
585 if ((i2c->nmsgs == 1) && msg->len == 0) xiic_start_send()
589 xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data); xiic_start_send()
592 xiic_fill_tx_fifo(i2c); xiic_start_send()
595 xiic_irq_clr_en(i2c, XIIC_INTR_TX_EMPTY_MASK | XIIC_INTR_TX_ERROR_MASK | xiic_start_send()
601 struct xiic_i2c *i2c = dev_id; xiic_isr() local
608 dev_dbg(i2c->adap.dev.parent, "%s entry\n", __func__); xiic_isr()
610 isr = xiic_getreg32(i2c, XIIC_IISR_OFFSET); xiic_isr()
611 ier = xiic_getreg32(i2c, XIIC_IIER_OFFSET); xiic_isr()
619 static void __xiic_start_xfer(struct xiic_i2c *i2c) __xiic_start_xfer() argument
622 int fifo_space = xiic_tx_fifo_space(i2c); __xiic_start_xfer()
623 dev_dbg(i2c->adap.dev.parent, "%s entry, msg: %p, fifos space: %d\n", __xiic_start_xfer()
624 __func__, i2c->tx_msg, fifo_space); __xiic_start_xfer()
626 if (!i2c->tx_msg) __xiic_start_xfer()
629 i2c->rx_pos = 0; __xiic_start_xfer()
630 i2c->tx_pos = 0; __xiic_start_xfer()
631 i2c->state = STATE_START; __xiic_start_xfer()
632 while ((fifo_space >= 2) && (first || (i2c->nmsgs > 1))) { __xiic_start_xfer()
634 i2c->nmsgs--; __xiic_start_xfer()
635 i2c->tx_msg++; __xiic_start_xfer()
636 i2c->tx_pos = 0; __xiic_start_xfer()
640 if (i2c->tx_msg->flags & I2C_M_RD) { __xiic_start_xfer()
642 xiic_start_recv(i2c); __xiic_start_xfer()
645 xiic_start_send(i2c); __xiic_start_xfer()
646 if (xiic_tx_space(i2c) != 0) { __xiic_start_xfer()
652 fifo_space = xiic_tx_fifo_space(i2c); __xiic_start_xfer()
658 if (i2c->nmsgs > 1 || xiic_tx_space(i2c)) __xiic_start_xfer()
659 xiic_irq_clr_en(i2c, XIIC_INTR_TX_HALF_MASK); __xiic_start_xfer()
663 static void xiic_start_xfer(struct xiic_i2c *i2c) xiic_start_xfer() argument
665 spin_lock(&i2c->lock); xiic_start_xfer()
666 xiic_reinit(i2c); xiic_start_xfer()
667 __xiic_start_xfer(i2c); xiic_start_xfer()
668 spin_unlock(&i2c->lock); xiic_start_xfer()
673 struct xiic_i2c *i2c = i2c_get_adapdata(adap); xiic_xfer() local
677 xiic_getreg8(i2c, XIIC_SR_REG_OFFSET)); xiic_xfer()
679 err = xiic_busy(i2c); xiic_xfer()
683 i2c->tx_msg = msgs; xiic_xfer()
684 i2c->nmsgs = num; xiic_xfer()
686 xiic_start_xfer(i2c); xiic_xfer()
688 if (wait_event_timeout(i2c->wait, (i2c->state == STATE_ERROR) || xiic_xfer()
689 (i2c->state == STATE_DONE), HZ)) xiic_xfer()
690 return (i2c->state == STATE_DONE) ? num : -EIO; xiic_xfer()
692 i2c->tx_msg = NULL; xiic_xfer()
693 i2c->rx_msg = NULL; xiic_xfer()
694 i2c->nmsgs = 0; xiic_xfer()
719 struct xiic_i2c *i2c; xiic_i2c_probe() local
726 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); xiic_i2c_probe()
727 if (!i2c) xiic_i2c_probe()
731 i2c->base = devm_ioremap_resource(&pdev->dev, res); xiic_i2c_probe()
732 if (IS_ERR(i2c->base)) xiic_i2c_probe()
733 return PTR_ERR(i2c->base); xiic_i2c_probe()
742 platform_set_drvdata(pdev, i2c); xiic_i2c_probe()
743 i2c->adap = xiic_adapter; xiic_i2c_probe()
744 i2c_set_adapdata(&i2c->adap, i2c); xiic_i2c_probe()
745 i2c->adap.dev.parent = &pdev->dev; xiic_i2c_probe()
746 i2c->adap.dev.of_node = pdev->dev.of_node; xiic_i2c_probe()
748 spin_lock_init(&i2c->lock); xiic_i2c_probe()
749 init_waitqueue_head(&i2c->wait); xiic_i2c_probe()
753 pdev->name, i2c); xiic_i2c_probe()
765 i2c->endianness = LITTLE; xiic_i2c_probe()
766 xiic_setreg32(i2c, XIIC_CR_REG_OFFSET, XIIC_CR_TX_FIFO_RESET_MASK); xiic_i2c_probe()
768 sr = xiic_getreg32(i2c, XIIC_SR_REG_OFFSET); xiic_i2c_probe()
770 i2c->endianness = BIG; xiic_i2c_probe()
772 xiic_reinit(i2c); xiic_i2c_probe()
774 /* add i2c adapter to i2c tree */ xiic_i2c_probe()
775 ret = i2c_add_adapter(&i2c->adap); xiic_i2c_probe()
778 xiic_deinit(i2c); xiic_i2c_probe()
785 i2c_new_device(&i2c->adap, pdata->devices + i); xiic_i2c_probe()
793 struct xiic_i2c *i2c = platform_get_drvdata(pdev); xiic_i2c_remove() local
796 i2c_del_adapter(&i2c->adap); xiic_i2c_remove()
798 xiic_deinit(i2c); xiic_i2c_remove()
H A Di2c-pca-platform.c19 #include <linux/i2c.h>
22 #include <linux/i2c-algo-pca.h>
23 #include <linux/i2c-pca-platform.h>
44 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_readbyte8() local
45 return ioread8(i2c->reg_base + reg); i2c_pca_pf_readbyte8()
50 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_readbyte16() local
51 return ioread8(i2c->reg_base + reg * 2); i2c_pca_pf_readbyte16()
56 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_readbyte32() local
57 return ioread8(i2c->reg_base + reg * 4); i2c_pca_pf_readbyte32()
62 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_writebyte8() local
63 iowrite8(val, i2c->reg_base + reg); i2c_pca_pf_writebyte8()
68 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_writebyte16() local
69 iowrite8(val, i2c->reg_base + reg * 2); i2c_pca_pf_writebyte16()
74 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_writebyte32() local
75 iowrite8(val, i2c->reg_base + reg * 4); i2c_pca_pf_writebyte32()
81 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_waitforcompletion() local
85 if (i2c->irq) { i2c_pca_pf_waitforcompletion()
86 ret = wait_event_timeout(i2c->wait, i2c_pca_pf_waitforcompletion()
87 i2c->algo_data.read_byte(i2c, I2C_PCA_CON) i2c_pca_pf_waitforcompletion()
88 & I2C_PCA_CON_SI, i2c->adap.timeout); i2c_pca_pf_waitforcompletion()
91 timeout = jiffies + i2c->adap.timeout; i2c_pca_pf_waitforcompletion()
94 if (i2c->algo_data.read_byte(i2c, I2C_PCA_CON) i2c_pca_pf_waitforcompletion()
106 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_dummyreset() local
108 i2c->adap.name); i2c_pca_pf_dummyreset()
113 struct i2c_pca_pf_data *i2c = pd; i2c_pca_pf_resetchip() local
115 gpio_set_value(i2c->gpio, 0); i2c_pca_pf_resetchip()
117 gpio_set_value(i2c->gpio, 1); i2c_pca_pf_resetchip()
122 struct i2c_pca_pf_data *i2c = dev_id; i2c_pca_pf_handler() local
124 if ((i2c->algo_data.read_byte(i2c, I2C_PCA_CON) & I2C_PCA_CON_SI) == 0) i2c_pca_pf_handler()
127 wake_up(&i2c->wait); i2c_pca_pf_handler()
135 struct i2c_pca_pf_data *i2c; i2c_pca_pf_probe() local
156 i2c = kzalloc(sizeof(struct i2c_pca_pf_data), GFP_KERNEL); i2c_pca_pf_probe()
157 if (!i2c) { i2c_pca_pf_probe()
162 init_waitqueue_head(&i2c->wait); i2c_pca_pf_probe()
164 i2c->reg_base = ioremap(res->start, resource_size(res)); i2c_pca_pf_probe()
165 if (!i2c->reg_base) { i2c_pca_pf_probe()
169 i2c->io_base = res->start; i2c_pca_pf_probe()
170 i2c->io_size = resource_size(res); i2c_pca_pf_probe()
171 i2c->irq = irq; i2c_pca_pf_probe()
173 i2c->adap.nr = pdev->id; i2c_pca_pf_probe()
174 i2c->adap.owner = THIS_MODULE; i2c_pca_pf_probe()
175 snprintf(i2c->adap.name, sizeof(i2c->adap.name), i2c_pca_pf_probe()
178 i2c->adap.algo_data = &i2c->algo_data; i2c_pca_pf_probe()
179 i2c->adap.dev.parent = &pdev->dev; i2c_pca_pf_probe()
182 i2c->adap.timeout = platform_data->timeout; i2c_pca_pf_probe()
183 i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed; i2c_pca_pf_probe()
184 i2c->gpio = platform_data->gpio; i2c_pca_pf_probe()
186 i2c->adap.timeout = HZ; i2c_pca_pf_probe()
187 i2c->algo_data.i2c_clock = 59000; i2c_pca_pf_probe()
188 i2c->gpio = -1; i2c_pca_pf_probe()
191 i2c->algo_data.data = i2c; i2c_pca_pf_probe()
192 i2c->algo_data.wait_for_completion = i2c_pca_pf_waitforcompletion; i2c_pca_pf_probe()
193 i2c->algo_data.reset_chip = i2c_pca_pf_dummyreset; i2c_pca_pf_probe()
197 i2c->algo_data.write_byte = i2c_pca_pf_writebyte32; i2c_pca_pf_probe()
198 i2c->algo_data.read_byte = i2c_pca_pf_readbyte32; i2c_pca_pf_probe()
201 i2c->algo_data.write_byte = i2c_pca_pf_writebyte16; i2c_pca_pf_probe()
202 i2c->algo_data.read_byte = i2c_pca_pf_readbyte16; i2c_pca_pf_probe()
206 i2c->algo_data.write_byte = i2c_pca_pf_writebyte8; i2c_pca_pf_probe()
207 i2c->algo_data.read_byte = i2c_pca_pf_readbyte8; i2c_pca_pf_probe()
212 if (i2c->gpio > -1) { i2c_pca_pf_probe()
213 ret = gpio_request(i2c->gpio, i2c->adap.name); i2c_pca_pf_probe()
215 gpio_direction_output(i2c->gpio, 1); i2c_pca_pf_probe()
216 i2c->algo_data.reset_chip = i2c_pca_pf_resetchip; i2c_pca_pf_probe()
219 i2c->adap.name); i2c_pca_pf_probe()
220 i2c->gpio = ret; i2c_pca_pf_probe()
226 IRQF_TRIGGER_FALLING, pdev->name, i2c); i2c_pca_pf_probe()
231 if (i2c_pca_add_numbered_bus(&i2c->adap) < 0) { i2c_pca_pf_probe()
236 platform_set_drvdata(pdev, i2c); i2c_pca_pf_probe()
238 printk(KERN_INFO "%s registered.\n", i2c->adap.name); i2c_pca_pf_probe()
244 free_irq(irq, i2c); i2c_pca_pf_probe()
246 if (i2c->gpio > -1) i2c_pca_pf_probe()
247 gpio_free(i2c->gpio); i2c_pca_pf_probe()
249 iounmap(i2c->reg_base); i2c_pca_pf_probe()
251 kfree(i2c); i2c_pca_pf_probe()
261 struct i2c_pca_pf_data *i2c = platform_get_drvdata(pdev); i2c_pca_pf_remove() local
263 i2c_del_adapter(&i2c->adap); i2c_pca_pf_remove()
265 if (i2c->irq) i2c_pca_pf_remove()
266 free_irq(i2c->irq, i2c); i2c_pca_pf_remove()
268 if (i2c->gpio > -1) i2c_pca_pf_remove()
269 gpio_free(i2c->gpio); i2c_pca_pf_remove()
271 iounmap(i2c->reg_base); i2c_pca_pf_remove()
272 release_mem_region(i2c->io_base, i2c->io_size); i2c_pca_pf_remove()
273 kfree(i2c); i2c_pca_pf_remove()
282 .name = "i2c-pca-platform",
H A Di2c-versatile.c2 * i2c-versatile.c
13 #include <linux/i2c.h>
14 #include <linux/i2c-algo-bit.h>
34 struct i2c_versatile *i2c = data; i2c_versatile_setsda() local
36 writel(SDA, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC)); i2c_versatile_setsda()
41 struct i2c_versatile *i2c = data; i2c_versatile_setscl() local
43 writel(SCL, i2c->base + (state ? I2C_CONTROLS : I2C_CONTROLC)); i2c_versatile_setscl()
48 struct i2c_versatile *i2c = data; i2c_versatile_getsda() local
49 return !!(readl(i2c->base + I2C_CONTROL) & SDA); i2c_versatile_getsda()
54 struct i2c_versatile *i2c = data; i2c_versatile_getscl() local
55 return !!(readl(i2c->base + I2C_CONTROL) & SCL); i2c_versatile_getscl()
69 struct i2c_versatile *i2c; i2c_versatile_probe() local
79 if (!request_mem_region(r->start, resource_size(r), "versatile-i2c")) { i2c_versatile_probe()
84 i2c = kzalloc(sizeof(struct i2c_versatile), GFP_KERNEL); i2c_versatile_probe()
85 if (!i2c) { i2c_versatile_probe()
90 i2c->base = ioremap(r->start, resource_size(r)); i2c_versatile_probe()
91 if (!i2c->base) { i2c_versatile_probe()
96 writel(SCL | SDA, i2c->base + I2C_CONTROLS); i2c_versatile_probe()
98 i2c->adap.owner = THIS_MODULE; i2c_versatile_probe()
99 strlcpy(i2c->adap.name, "Versatile I2C adapter", sizeof(i2c->adap.name)); i2c_versatile_probe()
100 i2c->adap.algo_data = &i2c->algo; i2c_versatile_probe()
101 i2c->adap.dev.parent = &dev->dev; i2c_versatile_probe()
102 i2c->adap.dev.of_node = dev->dev.of_node; i2c_versatile_probe()
103 i2c->algo = i2c_versatile_algo; i2c_versatile_probe()
104 i2c->algo.data = i2c; i2c_versatile_probe()
106 i2c->adap.nr = dev->id; i2c_versatile_probe()
107 ret = i2c_bit_add_numbered_bus(&i2c->adap); i2c_versatile_probe()
109 platform_set_drvdata(dev, i2c); i2c_versatile_probe()
113 iounmap(i2c->base); i2c_versatile_probe()
115 kfree(i2c); i2c_versatile_probe()
124 struct i2c_versatile *i2c = platform_get_drvdata(dev); i2c_versatile_remove() local
126 i2c_del_adapter(&i2c->adap); i2c_versatile_remove()
131 { .compatible = "arm,versatile-i2c", },
140 .name = "versatile-i2c",
160 MODULE_ALIAS("platform:versatile-i2c");
H A Di2c-s3c2410.c1 /* linux/drivers/i2c/busses/i2c-s3c2410.c
22 #include <linux/i2c.h>
43 #include <linux/platform_data/i2c-s3c2410.h>
95 /* i2c controller state */
137 .name = "s3c2410-i2c",
140 .name = "s3c2440-i2c",
143 .name = "s3c2440-hdmiphy-i2c",
149 static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat);
153 { .compatible = "samsung,s3c2410-i2c", .data = (void *)0 },
154 { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 },
155 { .compatible = "samsung,s3c2440-hdmiphy-i2c",
157 { .compatible = "samsung,exynos5440-i2c",
159 { .compatible = "samsung,exynos5-sata-phy-i2c",
188 static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret) s3c24xx_i2c_master_complete() argument
190 dev_dbg(i2c->dev, "master_complete %d\n", ret); s3c24xx_i2c_master_complete()
192 i2c->msg_ptr = 0; s3c24xx_i2c_master_complete()
193 i2c->msg = NULL; s3c24xx_i2c_master_complete()
194 i2c->msg_idx++; s3c24xx_i2c_master_complete()
195 i2c->msg_num = 0; s3c24xx_i2c_master_complete()
197 i2c->msg_idx = ret; s3c24xx_i2c_master_complete()
199 if (!(i2c->quirks & QUIRK_POLL)) s3c24xx_i2c_master_complete()
200 wake_up(&i2c->wait); s3c24xx_i2c_master_complete()
203 static inline void s3c24xx_i2c_disable_ack(struct s3c24xx_i2c *i2c) s3c24xx_i2c_disable_ack() argument
207 tmp = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_disable_ack()
208 writel(tmp & ~S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_disable_ack()
211 static inline void s3c24xx_i2c_enable_ack(struct s3c24xx_i2c *i2c) s3c24xx_i2c_enable_ack() argument
215 tmp = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_enable_ack()
216 writel(tmp | S3C2410_IICCON_ACKEN, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_enable_ack()
221 static inline void s3c24xx_i2c_disable_irq(struct s3c24xx_i2c *i2c) s3c24xx_i2c_disable_irq() argument
225 tmp = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_disable_irq()
226 writel(tmp & ~S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_disable_irq()
229 static inline void s3c24xx_i2c_enable_irq(struct s3c24xx_i2c *i2c) s3c24xx_i2c_enable_irq() argument
233 tmp = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_enable_irq()
234 writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_enable_irq()
237 static bool is_ack(struct s3c24xx_i2c *i2c) is_ack() argument
242 if (readl(i2c->regs + S3C2410_IICCON) is_ack()
244 if (!(readl(i2c->regs + S3C2410_IICSTAT) is_ack()
250 dev_err(i2c->dev, "ack was not received\n"); is_ack()
259 static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, s3c24xx_i2c_message_start() argument
279 s3c24xx_i2c_enable_ack(i2c); s3c24xx_i2c_message_start()
281 iiccon = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_message_start()
282 writel(stat, i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_message_start()
284 dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr); s3c24xx_i2c_message_start()
285 writeb(addr, i2c->regs + S3C2410_IICDS); s3c24xx_i2c_message_start()
290 ndelay(i2c->tx_setup); s3c24xx_i2c_message_start()
292 dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon); s3c24xx_i2c_message_start()
293 writel(iiccon, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_message_start()
296 writel(stat, i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_message_start()
298 if (i2c->quirks & QUIRK_POLL) { s3c24xx_i2c_message_start()
299 while ((i2c->msg_num != 0) && is_ack(i2c)) { s3c24xx_i2c_message_start()
300 i2c_s3c_irq_nextbyte(i2c, stat); s3c24xx_i2c_message_start()
301 stat = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_message_start()
304 dev_err(i2c->dev, "deal with arbitration loss\n"); s3c24xx_i2c_message_start()
309 static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret) s3c24xx_i2c_stop() argument
311 unsigned long iicstat = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_stop()
313 dev_dbg(i2c->dev, "STOP\n"); s3c24xx_i2c_stop()
349 if (i2c->quirks & QUIRK_HDMIPHY) { s3c24xx_i2c_stop()
356 writel(iicstat, i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_stop()
358 i2c->state = STATE_STOP; s3c24xx_i2c_stop()
360 s3c24xx_i2c_master_complete(i2c, ret); s3c24xx_i2c_stop()
361 s3c24xx_i2c_disable_irq(i2c); s3c24xx_i2c_stop()
372 static inline int is_lastmsg(struct s3c24xx_i2c *i2c) is_lastmsg() argument
374 return i2c->msg_idx >= (i2c->msg_num - 1); is_lastmsg()
382 static inline int is_msglast(struct s3c24xx_i2c *i2c) is_msglast() argument
387 if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) is_msglast()
390 return i2c->msg_ptr == i2c->msg->len-1; is_msglast()
398 static inline int is_msgend(struct s3c24xx_i2c *i2c) is_msgend() argument
400 return i2c->msg_ptr >= i2c->msg->len; is_msgend()
408 static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat) i2c_s3c_irq_nextbyte() argument
414 switch (i2c->state) { i2c_s3c_irq_nextbyte()
417 dev_err(i2c->dev, "%s: called in STATE_IDLE\n", __func__); i2c_s3c_irq_nextbyte()
421 dev_err(i2c->dev, "%s: called in STATE_STOP\n", __func__); i2c_s3c_irq_nextbyte()
422 s3c24xx_i2c_disable_irq(i2c); i2c_s3c_irq_nextbyte()
427 * bus, or started a new i2c message i2c_s3c_irq_nextbyte()
431 !(i2c->msg->flags & I2C_M_IGNORE_NAK)) { i2c_s3c_irq_nextbyte()
434 dev_dbg(i2c->dev, "ack was not received\n"); i2c_s3c_irq_nextbyte()
435 s3c24xx_i2c_stop(i2c, -ENXIO); i2c_s3c_irq_nextbyte()
439 if (i2c->msg->flags & I2C_M_RD) i2c_s3c_irq_nextbyte()
440 i2c->state = STATE_READ; i2c_s3c_irq_nextbyte()
442 i2c->state = STATE_WRITE; i2c_s3c_irq_nextbyte()
445 * as this is used by the i2c probe to find devices. */ i2c_s3c_irq_nextbyte()
447 if (is_lastmsg(i2c) && i2c->msg->len == 0) { i2c_s3c_irq_nextbyte()
448 s3c24xx_i2c_stop(i2c, 0); i2c_s3c_irq_nextbyte()
452 if (i2c->state == STATE_READ) i2c_s3c_irq_nextbyte()
463 if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) { i2c_s3c_irq_nextbyte()
465 dev_dbg(i2c->dev, "WRITE: No Ack\n"); i2c_s3c_irq_nextbyte()
467 s3c24xx_i2c_stop(i2c, -ECONNREFUSED); i2c_s3c_irq_nextbyte()
474 if (!is_msgend(i2c)) { i2c_s3c_irq_nextbyte()
475 byte = i2c->msg->buf[i2c->msg_ptr++]; i2c_s3c_irq_nextbyte()
476 writeb(byte, i2c->regs + S3C2410_IICDS); i2c_s3c_irq_nextbyte()
484 ndelay(i2c->tx_setup); i2c_s3c_irq_nextbyte()
486 } else if (!is_lastmsg(i2c)) { i2c_s3c_irq_nextbyte()
487 /* we need to go to the next i2c message */ i2c_s3c_irq_nextbyte()
489 dev_dbg(i2c->dev, "WRITE: Next Message\n"); i2c_s3c_irq_nextbyte()
491 i2c->msg_ptr = 0; i2c_s3c_irq_nextbyte()
492 i2c->msg_idx++; i2c_s3c_irq_nextbyte()
493 i2c->msg++; i2c_s3c_irq_nextbyte()
496 if (i2c->msg->flags & I2C_M_NOSTART) { i2c_s3c_irq_nextbyte()
498 if (i2c->msg->flags & I2C_M_RD) { i2c_s3c_irq_nextbyte()
503 s3c24xx_i2c_stop(i2c, -EINVAL); i2c_s3c_irq_nextbyte()
509 s3c24xx_i2c_message_start(i2c, i2c->msg); i2c_s3c_irq_nextbyte()
510 i2c->state = STATE_START; i2c_s3c_irq_nextbyte()
516 s3c24xx_i2c_stop(i2c, 0); i2c_s3c_irq_nextbyte()
526 byte = readb(i2c->regs + S3C2410_IICDS); i2c_s3c_irq_nextbyte()
527 i2c->msg->buf[i2c->msg_ptr++] = byte; i2c_s3c_irq_nextbyte()
530 if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1) i2c_s3c_irq_nextbyte()
531 i2c->msg->len += byte; i2c_s3c_irq_nextbyte()
533 if (is_msglast(i2c)) { i2c_s3c_irq_nextbyte()
536 if (is_lastmsg(i2c)) i2c_s3c_irq_nextbyte()
537 s3c24xx_i2c_disable_ack(i2c); i2c_s3c_irq_nextbyte()
539 } else if (is_msgend(i2c)) { i2c_s3c_irq_nextbyte()
543 if (is_lastmsg(i2c)) { i2c_s3c_irq_nextbyte()
545 dev_dbg(i2c->dev, "READ: Send Stop\n"); i2c_s3c_irq_nextbyte()
547 s3c24xx_i2c_stop(i2c, 0); i2c_s3c_irq_nextbyte()
550 dev_dbg(i2c->dev, "READ: Next Transfer\n"); i2c_s3c_irq_nextbyte()
552 i2c->msg_ptr = 0; i2c_s3c_irq_nextbyte()
553 i2c->msg_idx++; i2c_s3c_irq_nextbyte()
554 i2c->msg++; i2c_s3c_irq_nextbyte()
564 tmp = readl(i2c->regs + S3C2410_IICCON); i2c_s3c_irq_nextbyte()
566 writel(tmp, i2c->regs + S3C2410_IICCON); i2c_s3c_irq_nextbyte()
578 struct s3c24xx_i2c *i2c = dev_id; s3c24xx_i2c_irq() local
582 status = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_irq()
586 dev_err(i2c->dev, "deal with arbitration loss\n"); s3c24xx_i2c_irq()
589 if (i2c->state == STATE_IDLE) { s3c24xx_i2c_irq()
590 dev_dbg(i2c->dev, "IRQ: error i2c->state == IDLE\n"); s3c24xx_i2c_irq()
592 tmp = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_irq()
594 writel(tmp, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_irq()
601 i2c_s3c_irq_nextbyte(i2c, status); s3c24xx_i2c_irq()
616 static inline void s3c24xx_i2c_disable_bus(struct s3c24xx_i2c *i2c) s3c24xx_i2c_disable_bus() argument
621 tmp = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_disable_bus()
623 writel(tmp, i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_disable_bus()
626 tmp = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_disable_bus()
629 writel(tmp, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_disable_bus()
635 * get the i2c bus for a master transaction
638 static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c) s3c24xx_i2c_set_master() argument
644 iicstat = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_set_master()
657 * wait for the i2c bus to become idle.
660 static void s3c24xx_i2c_wait_idle(struct s3c24xx_i2c *i2c) s3c24xx_i2c_wait_idle() argument
669 dev_dbg(i2c->dev, "waiting for bus idle\n"); s3c24xx_i2c_wait_idle()
675 * end of a transaction. However, really slow i2c devices can stretch s3c24xx_i2c_wait_idle()
682 iicstat = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_wait_idle()
685 iicstat = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_wait_idle()
702 iicstat = readl(i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_wait_idle()
706 dev_warn(i2c->dev, "timeout waiting for bus idle\n"); s3c24xx_i2c_wait_idle()
711 * this starts an i2c transfer
714 static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, s3c24xx_i2c_doxfer() argument
720 if (i2c->suspended) s3c24xx_i2c_doxfer()
723 ret = s3c24xx_i2c_set_master(i2c); s3c24xx_i2c_doxfer()
725 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); s3c24xx_i2c_doxfer()
730 i2c->msg = msgs; s3c24xx_i2c_doxfer()
731 i2c->msg_num = num; s3c24xx_i2c_doxfer()
732 i2c->msg_ptr = 0; s3c24xx_i2c_doxfer()
733 i2c->msg_idx = 0; s3c24xx_i2c_doxfer()
734 i2c->state = STATE_START; s3c24xx_i2c_doxfer()
736 s3c24xx_i2c_enable_irq(i2c); s3c24xx_i2c_doxfer()
737 s3c24xx_i2c_message_start(i2c, msgs); s3c24xx_i2c_doxfer()
739 if (i2c->quirks & QUIRK_POLL) { s3c24xx_i2c_doxfer()
740 ret = i2c->msg_idx; s3c24xx_i2c_doxfer()
743 dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); s3c24xx_i2c_doxfer()
748 timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); s3c24xx_i2c_doxfer()
750 ret = i2c->msg_idx; s3c24xx_i2c_doxfer()
756 dev_dbg(i2c->dev, "timeout\n"); s3c24xx_i2c_doxfer()
758 dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); s3c24xx_i2c_doxfer()
761 if (i2c->quirks & QUIRK_HDMIPHY) s3c24xx_i2c_doxfer()
764 s3c24xx_i2c_wait_idle(i2c); s3c24xx_i2c_doxfer()
766 s3c24xx_i2c_disable_bus(i2c); s3c24xx_i2c_doxfer()
769 i2c->state = STATE_IDLE; s3c24xx_i2c_doxfer()
776 * first port of call from the i2c bus code when an message needs
777 * transferring across the i2c bus.
783 struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data; s3c24xx_i2c_xfer() local
788 ret = clk_enable(i2c->clk); s3c24xx_i2c_xfer()
794 ret = s3c24xx_i2c_doxfer(i2c, msgs, num); s3c24xx_i2c_xfer()
797 clk_disable(i2c->clk); s3c24xx_i2c_xfer()
802 dev_dbg(i2c->dev, "Retrying transmission (%d)\n", retry); s3c24xx_i2c_xfer()
807 clk_disable(i2c->clk); s3c24xx_i2c_xfer()
812 /* declare our i2c functionality */ s3c24xx_i2c_func()
819 /* i2c bus registration info */
863 static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) s3c24xx_i2c_clockrate() argument
865 struct s3c2410_platform_i2c *pdata = i2c->pdata; s3c24xx_i2c_clockrate()
866 unsigned long clkin = clk_get_rate(i2c->clk); s3c24xx_i2c_clockrate()
872 i2c->clkrate = clkin; s3c24xx_i2c_clockrate()
875 dev_dbg(i2c->dev, "pdata desired frequency %lu\n", pdata->frequency); s3c24xx_i2c_clockrate()
884 dev_err(i2c->dev, s3c24xx_i2c_clockrate()
892 iiccon = readl(i2c->regs + S3C2410_IICCON); s3c24xx_i2c_clockrate()
899 if (i2c->quirks & QUIRK_POLL) s3c24xx_i2c_clockrate()
902 writel(iiccon, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_clockrate()
904 if (i2c->quirks & QUIRK_S3C2440) { s3c24xx_i2c_clockrate()
917 dev_dbg(i2c->dev, "IICLC=%08lx\n", sda_delay); s3c24xx_i2c_clockrate()
918 writel(sda_delay, i2c->regs + S3C2440_IICLC); s3c24xx_i2c_clockrate()
931 struct s3c24xx_i2c *i2c = freq_to_i2c(nb); s3c24xx_i2c_cpufreq_transition() local
936 delta_f = clk_get_rate(i2c->clk) - i2c->clkrate; s3c24xx_i2c_cpufreq_transition()
945 i2c_lock_adapter(&i2c->adap); s3c24xx_i2c_cpufreq_transition()
946 ret = s3c24xx_i2c_clockrate(i2c, &got); s3c24xx_i2c_cpufreq_transition()
947 i2c_unlock_adapter(&i2c->adap); s3c24xx_i2c_cpufreq_transition()
950 dev_err(i2c->dev, "cannot find frequency\n"); s3c24xx_i2c_cpufreq_transition()
952 dev_info(i2c->dev, "setting freq %d\n", got); s3c24xx_i2c_cpufreq_transition()
958 static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c) s3c24xx_i2c_register_cpufreq() argument
960 i2c->freq_transition.notifier_call = s3c24xx_i2c_cpufreq_transition; s3c24xx_i2c_register_cpufreq()
962 return cpufreq_register_notifier(&i2c->freq_transition, s3c24xx_i2c_register_cpufreq()
966 static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c) s3c24xx_i2c_deregister_cpufreq() argument
968 cpufreq_unregister_notifier(&i2c->freq_transition, s3c24xx_i2c_deregister_cpufreq()
973 static inline int s3c24xx_i2c_register_cpufreq(struct s3c24xx_i2c *i2c) s3c24xx_i2c_register_cpufreq() argument
978 static inline void s3c24xx_i2c_deregister_cpufreq(struct s3c24xx_i2c *i2c) s3c24xx_i2c_deregister_cpufreq() argument
984 static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c) s3c24xx_i2c_parse_dt_gpio() argument
988 if (i2c->quirks & QUIRK_NO_GPIO) s3c24xx_i2c_parse_dt_gpio()
992 gpio = of_get_gpio(i2c->dev->of_node, idx); s3c24xx_i2c_parse_dt_gpio()
994 dev_err(i2c->dev, "invalid gpio[%d]: %d\n", idx, gpio); s3c24xx_i2c_parse_dt_gpio()
997 i2c->gpios[idx] = gpio; s3c24xx_i2c_parse_dt_gpio()
999 ret = gpio_request(gpio, "i2c-bus"); s3c24xx_i2c_parse_dt_gpio()
1001 dev_err(i2c->dev, "gpio [%d] request failed\n", gpio); s3c24xx_i2c_parse_dt_gpio()
1009 gpio_free(i2c->gpios[idx]); s3c24xx_i2c_parse_dt_gpio()
1013 static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c) s3c24xx_i2c_dt_gpio_free() argument
1017 if (i2c->quirks & QUIRK_NO_GPIO) s3c24xx_i2c_dt_gpio_free()
1021 gpio_free(i2c->gpios[idx]); s3c24xx_i2c_dt_gpio_free()
1024 static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c) s3c24xx_i2c_parse_dt_gpio() argument
1029 static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c) s3c24xx_i2c_dt_gpio_free() argument
1039 static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c) s3c24xx_i2c_init() argument
1046 pdata = i2c->pdata; s3c24xx_i2c_init()
1050 writeb(pdata->slave_addr, i2c->regs + S3C2410_IICADD); s3c24xx_i2c_init()
1052 dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr); s3c24xx_i2c_init()
1054 writel(0, i2c->regs + S3C2410_IICCON); s3c24xx_i2c_init()
1055 writel(0, i2c->regs + S3C2410_IICSTAT); s3c24xx_i2c_init()
1059 if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) { s3c24xx_i2c_init()
1060 dev_err(i2c->dev, "cannot meet bus frequency required\n"); s3c24xx_i2c_init()
1064 /* todo - check that the i2c lines aren't being dragged anywhere */ s3c24xx_i2c_init()
1066 dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq); s3c24xx_i2c_init()
1067 dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02x\n", s3c24xx_i2c_init()
1068 readl(i2c->regs + S3C2410_IICCON)); s3c24xx_i2c_init()
1080 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) s3c24xx_i2c_parse_dt() argument
1082 struct s3c2410_platform_i2c *pdata = i2c->pdata; s3c24xx_i2c_parse_dt()
1088 pdata->bus_num = -1; /* i2c bus number is dynamically assigned */ s3c24xx_i2c_parse_dt()
1089 of_property_read_u32(np, "samsung,i2c-sda-delay", &pdata->sda_delay); s3c24xx_i2c_parse_dt()
1090 of_property_read_u32(np, "samsung,i2c-slave-addr", &pdata->slave_addr); s3c24xx_i2c_parse_dt()
1091 of_property_read_u32(np, "samsung,i2c-max-bus-freq", s3c24xx_i2c_parse_dt()
1094 * Exynos5's legacy i2c controller and new high speed i2c s3c24xx_i2c_parse_dt()
1097 * If nodes for first four channels of legacy i2c controller s3c24xx_i2c_parse_dt()
1101 id = of_alias_get_id(np, "i2c"); s3c24xx_i2c_parse_dt()
1102 i2c->sysreg = syscon_regmap_lookup_by_phandle(np, s3c24xx_i2c_parse_dt()
1104 if (IS_ERR(i2c->sysreg)) s3c24xx_i2c_parse_dt()
1107 regmap_update_bits(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, BIT(id), 0); s3c24xx_i2c_parse_dt()
1111 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c) s3c24xx_i2c_parse_dt() argument
1124 struct s3c24xx_i2c *i2c; s3c24xx_i2c_probe() local
1137 i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL); s3c24xx_i2c_probe()
1138 if (!i2c) s3c24xx_i2c_probe()
1141 i2c->pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); s3c24xx_i2c_probe()
1142 if (!i2c->pdata) s3c24xx_i2c_probe()
1145 i2c->quirks = s3c24xx_get_device_quirks(pdev); s3c24xx_i2c_probe()
1146 i2c->sysreg = ERR_PTR(-ENOENT); s3c24xx_i2c_probe()
1148 memcpy(i2c->pdata, pdata, sizeof(*pdata)); s3c24xx_i2c_probe()
1150 s3c24xx_i2c_parse_dt(pdev->dev.of_node, i2c); s3c24xx_i2c_probe()
1152 strlcpy(i2c->adap.name, "s3c2410-i2c", sizeof(i2c->adap.name)); s3c24xx_i2c_probe()
1153 i2c->adap.owner = THIS_MODULE; s3c24xx_i2c_probe()
1154 i2c->adap.algo = &s3c24xx_i2c_algorithm; s3c24xx_i2c_probe()
1155 i2c->adap.retries = 2; s3c24xx_i2c_probe()
1156 i2c->adap.class = I2C_CLASS_DEPRECATED; s3c24xx_i2c_probe()
1157 i2c->tx_setup = 50; s3c24xx_i2c_probe()
1159 init_waitqueue_head(&i2c->wait); s3c24xx_i2c_probe()
1163 i2c->dev = &pdev->dev; s3c24xx_i2c_probe()
1164 i2c->clk = devm_clk_get(&pdev->dev, "i2c"); s3c24xx_i2c_probe()
1165 if (IS_ERR(i2c->clk)) { s3c24xx_i2c_probe()
1170 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); s3c24xx_i2c_probe()
1176 i2c->regs = devm_ioremap_resource(&pdev->dev, res); s3c24xx_i2c_probe()
1178 if (IS_ERR(i2c->regs)) s3c24xx_i2c_probe()
1179 return PTR_ERR(i2c->regs); s3c24xx_i2c_probe()
1182 i2c->regs, res); s3c24xx_i2c_probe()
1184 /* setup info block for the i2c core */ s3c24xx_i2c_probe()
1186 i2c->adap.algo_data = i2c; s3c24xx_i2c_probe()
1187 i2c->adap.dev.parent = &pdev->dev; s3c24xx_i2c_probe()
1189 i2c->pctrl = devm_pinctrl_get_select_default(i2c->dev); s3c24xx_i2c_probe()
1191 /* inititalise the i2c gpio lines */ s3c24xx_i2c_probe()
1193 if (i2c->pdata->cfg_gpio) { s3c24xx_i2c_probe()
1194 i2c->pdata->cfg_gpio(to_platform_device(i2c->dev)); s3c24xx_i2c_probe()
1195 } else if (IS_ERR(i2c->pctrl) && s3c24xx_i2c_parse_dt_gpio(i2c)) { s3c24xx_i2c_probe()
1199 /* initialise the i2c controller */ s3c24xx_i2c_probe()
1201 clk_prepare_enable(i2c->clk); s3c24xx_i2c_probe()
1202 ret = s3c24xx_i2c_init(i2c); s3c24xx_i2c_probe()
1203 clk_disable(i2c->clk); s3c24xx_i2c_probe()
1212 if (!(i2c->quirks & QUIRK_POLL)) { s3c24xx_i2c_probe()
1213 i2c->irq = ret = platform_get_irq(pdev, 0); s3c24xx_i2c_probe()
1216 clk_unprepare(i2c->clk); s3c24xx_i2c_probe()
1220 ret = devm_request_irq(&pdev->dev, i2c->irq, s3c24xx_i2c_irq, 0, s3c24xx_i2c_probe()
1221 dev_name(&pdev->dev), i2c); s3c24xx_i2c_probe()
1224 dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); s3c24xx_i2c_probe()
1225 clk_unprepare(i2c->clk); s3c24xx_i2c_probe()
1230 ret = s3c24xx_i2c_register_cpufreq(i2c); s3c24xx_i2c_probe()
1233 clk_unprepare(i2c->clk); s3c24xx_i2c_probe()
1243 i2c->adap.nr = i2c->pdata->bus_num; s3c24xx_i2c_probe()
1244 i2c->adap.dev.of_node = pdev->dev.of_node; s3c24xx_i2c_probe()
1246 platform_set_drvdata(pdev, i2c); s3c24xx_i2c_probe()
1250 ret = i2c_add_numbered_adapter(&i2c->adap); s3c24xx_i2c_probe()
1252 dev_err(&pdev->dev, "failed to add bus to i2c core\n"); s3c24xx_i2c_probe()
1254 s3c24xx_i2c_deregister_cpufreq(i2c); s3c24xx_i2c_probe()
1255 clk_unprepare(i2c->clk); s3c24xx_i2c_probe()
1259 pm_runtime_enable(&i2c->adap.dev); s3c24xx_i2c_probe()
1261 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev)); s3c24xx_i2c_probe()
1272 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); s3c24xx_i2c_remove() local
1274 clk_unprepare(i2c->clk); s3c24xx_i2c_remove()
1276 pm_runtime_disable(&i2c->adap.dev); s3c24xx_i2c_remove()
1279 s3c24xx_i2c_deregister_cpufreq(i2c); s3c24xx_i2c_remove()
1281 i2c_del_adapter(&i2c->adap); s3c24xx_i2c_remove()
1283 if (pdev->dev.of_node && IS_ERR(i2c->pctrl)) s3c24xx_i2c_remove()
1284 s3c24xx_i2c_dt_gpio_free(i2c); s3c24xx_i2c_remove()
1293 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); s3c24xx_i2c_suspend_noirq() local
1295 i2c->suspended = 1; s3c24xx_i2c_suspend_noirq()
1297 if (!IS_ERR(i2c->sysreg)) s3c24xx_i2c_suspend_noirq()
1298 regmap_read(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, &i2c->sys_i2c_cfg); s3c24xx_i2c_suspend_noirq()
1306 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); s3c24xx_i2c_resume_noirq() local
1309 if (!IS_ERR(i2c->sysreg)) s3c24xx_i2c_resume_noirq()
1310 regmap_write(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, i2c->sys_i2c_cfg); s3c24xx_i2c_resume_noirq()
1312 ret = clk_enable(i2c->clk); s3c24xx_i2c_resume_noirq()
1315 s3c24xx_i2c_init(i2c); s3c24xx_i2c_resume_noirq()
1316 clk_disable(i2c->clk); s3c24xx_i2c_resume_noirq()
1317 i2c->suspended = 0; s3c24xx_i2c_resume_noirq()
1347 .name = "s3c-i2c",
H A Di2c-jz4780.c23 #include <linux/i2c.h>
179 static inline unsigned short jz4780_i2c_readw(struct jz4780_i2c *i2c, jz4780_i2c_readw() argument
182 return readw(i2c->iomem + offset); jz4780_i2c_readw()
185 static inline void jz4780_i2c_writew(struct jz4780_i2c *i2c, jz4780_i2c_writew() argument
188 writew(val, i2c->iomem + offset); jz4780_i2c_writew()
191 static int jz4780_i2c_disable(struct jz4780_i2c *i2c) jz4780_i2c_disable() argument
196 jz4780_i2c_writew(i2c, JZ4780_I2C_ENB, 0); jz4780_i2c_disable()
199 regval = jz4780_i2c_readw(i2c, JZ4780_I2C_ENSTA); jz4780_i2c_disable()
206 dev_err(&i2c->adap.dev, "disable failed: ENSTA=0x%04x\n", regval); jz4780_i2c_disable()
210 static int jz4780_i2c_enable(struct jz4780_i2c *i2c) jz4780_i2c_enable() argument
215 jz4780_i2c_writew(i2c, JZ4780_I2C_ENB, 1); jz4780_i2c_enable()
218 regval = jz4780_i2c_readw(i2c, JZ4780_I2C_ENSTA); jz4780_i2c_enable()
225 dev_err(&i2c->adap.dev, "enable failed: ENSTA=0x%04x\n", regval); jz4780_i2c_enable()
229 static int jz4780_i2c_set_target(struct jz4780_i2c *i2c, unsigned char address) jz4780_i2c_set_target() argument
235 regval = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); jz4780_i2c_set_target()
244 jz4780_i2c_writew(i2c, JZ4780_I2C_TAR, address); jz4780_i2c_set_target()
248 dev_err(&i2c->adap.dev, jz4780_i2c_set_target()
255 static int jz4780_i2c_set_speed(struct jz4780_i2c *i2c) jz4780_i2c_set_speed() argument
257 int dev_clk_khz = clk_get_rate(i2c->clk) / 1000; jz4780_i2c_set_speed()
264 int i2c_clk = i2c->speed; jz4780_i2c_set_speed()
266 if (jz4780_i2c_disable(i2c)) jz4780_i2c_set_speed()
267 dev_dbg(&i2c->adap.dev, "i2c not disabled\n"); jz4780_i2c_set_speed()
284 * NOTE: JZ4780_I2C_CTRL_REST can't set when i2c enabled, because jz4780_i2c_set_speed()
285 * normal read are 2 messages, we cannot disable i2c controller jz4780_i2c_set_speed()
293 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_set_speed()
295 jz4780_i2c_writew(i2c, JZ4780_I2C_SHCNT, jz4780_i2c_set_speed()
297 jz4780_i2c_writew(i2c, JZ4780_I2C_SLCNT, jz4780_i2c_set_speed()
302 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_set_speed()
304 jz4780_i2c_writew(i2c, JZ4780_I2C_FHCNT, jz4780_i2c_set_speed()
306 jz4780_i2c_writew(i2c, JZ4780_I2C_FLCNT, jz4780_i2c_set_speed()
311 * a i2c device must internally provide a hold time at least 300ns jz4780_i2c_set_speed()
345 jz4780_i2c_writew(i2c, JZ4780_I2C_SDASU, setup_time); jz4780_i2c_set_speed()
351 /*i2c hold time enable */ jz4780_i2c_set_speed()
353 jz4780_i2c_writew(i2c, JZ4780_I2C_SDAHD, hold_time); jz4780_i2c_set_speed()
356 jz4780_i2c_writew(i2c, JZ4780_I2C_SDAHD, 0); jz4780_i2c_set_speed()
362 static int jz4780_i2c_cleanup(struct jz4780_i2c *i2c) jz4780_i2c_cleanup() argument
368 spin_lock_irqsave(&i2c->lock, flags); jz4780_i2c_cleanup()
371 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); jz4780_i2c_cleanup()
373 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_cleanup()
376 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0); jz4780_i2c_cleanup()
379 jz4780_i2c_readw(i2c, JZ4780_I2C_CTXABRT); jz4780_i2c_cleanup()
380 jz4780_i2c_readw(i2c, JZ4780_I2C_CINTR); jz4780_i2c_cleanup()
383 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); jz4780_i2c_cleanup()
385 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_cleanup()
388 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_cleanup()
390 spin_unlock_irqrestore(&i2c->lock, flags); jz4780_i2c_cleanup()
392 ret = jz4780_i2c_disable(i2c); jz4780_i2c_cleanup()
394 dev_err(&i2c->adap.dev, jz4780_i2c_cleanup()
397 if (unlikely(jz4780_i2c_readw(i2c, JZ4780_I2C_INTM) jz4780_i2c_cleanup()
398 & jz4780_i2c_readw(i2c, JZ4780_I2C_INTST))) jz4780_i2c_cleanup()
399 dev_err(&i2c->adap.dev, jz4780_i2c_cleanup()
405 static int jz4780_i2c_prepare(struct jz4780_i2c *i2c) jz4780_i2c_prepare() argument
407 jz4780_i2c_set_speed(i2c); jz4780_i2c_prepare()
408 return jz4780_i2c_enable(i2c); jz4780_i2c_prepare()
411 static void jz4780_i2c_send_rcmd(struct jz4780_i2c *i2c, int cmd_count) jz4780_i2c_send_rcmd() argument
416 jz4780_i2c_writew(i2c, JZ4780_I2C_DC, JZ4780_I2C_DC_READ); jz4780_i2c_send_rcmd()
419 static void jz4780_i2c_trans_done(struct jz4780_i2c *i2c) jz4780_i2c_trans_done() argument
421 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0); jz4780_i2c_trans_done()
422 complete(&i2c->trans_waitq); jz4780_i2c_trans_done()
430 struct jz4780_i2c *i2c = dev_id; jz4780_i2c_irq() local
433 spin_lock_irqsave(&i2c->lock, flags); jz4780_i2c_irq()
434 intmsk = jz4780_i2c_readw(i2c, JZ4780_I2C_INTM); jz4780_i2c_irq()
435 intst = jz4780_i2c_readw(i2c, JZ4780_I2C_INTST); jz4780_i2c_irq()
440 jz4780_i2c_trans_done(i2c); jz4780_i2c_irq()
445 dev_dbg(&i2c->adap.dev, "received fifo overflow!\n"); jz4780_i2c_irq()
446 jz4780_i2c_trans_done(i2c); jz4780_i2c_irq()
454 if (i2c->is_write == 0) { jz4780_i2c_irq()
457 while ((jz4780_i2c_readw(i2c, JZ4780_I2C_STA) jz4780_i2c_irq()
459 *(i2c->rbuf++) = jz4780_i2c_readw(i2c, JZ4780_I2C_DC) jz4780_i2c_irq()
461 i2c->rd_data_xfered++; jz4780_i2c_irq()
462 if (i2c->rd_data_xfered == i2c->rd_total_len) { jz4780_i2c_irq()
463 jz4780_i2c_trans_done(i2c); jz4780_i2c_irq()
468 rd_left = i2c->rd_total_len - i2c->rd_data_xfered; jz4780_i2c_irq()
471 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, rd_left - 1); jz4780_i2c_irq()
475 if (i2c->is_write == 0) { jz4780_i2c_irq()
476 int cmd_left = i2c->rd_total_len - i2c->rd_cmd_xfered; jz4780_i2c_irq()
478 - (i2c->rd_cmd_xfered jz4780_i2c_irq()
479 - i2c->rd_data_xfered); jz4780_i2c_irq()
482 if (i2c->rd_cmd_xfered != 0) jz4780_i2c_irq()
488 jz4780_i2c_send_rcmd(i2c, cmd_to_send); jz4780_i2c_irq()
489 i2c->rd_cmd_xfered += cmd_to_send; jz4780_i2c_irq()
492 cmd_left = i2c->rd_total_len - i2c->rd_cmd_xfered; jz4780_i2c_irq()
494 intmsk = jz4780_i2c_readw(i2c, JZ4780_I2C_INTM); jz4780_i2c_irq()
496 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, intmsk); jz4780_i2c_irq()
498 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); jz4780_i2c_irq()
500 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_irq()
506 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); jz4780_i2c_irq()
509 (i2c->wt_len > 0)) { jz4780_i2c_irq()
510 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); jz4780_i2c_irq()
511 data = *i2c->wbuf; jz4780_i2c_irq()
513 jz4780_i2c_writew(i2c, JZ4780_I2C_DC, jz4780_i2c_irq()
515 i2c->wbuf++; jz4780_i2c_irq()
516 i2c->wt_len--; jz4780_i2c_irq()
519 if (i2c->wt_len == 0) { jz4780_i2c_irq()
520 if (!i2c->stop_hold) { jz4780_i2c_irq()
521 tmp = jz4780_i2c_readw(i2c, jz4780_i2c_irq()
524 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, jz4780_i2c_irq()
528 jz4780_i2c_trans_done(i2c); jz4780_i2c_irq()
535 spin_unlock_irqrestore(&i2c->lock, flags); jz4780_i2c_irq()
539 static void jz4780_i2c_txabrt(struct jz4780_i2c *i2c, int src) jz4780_i2c_txabrt() argument
543 dev_err(&i2c->adap.dev, "txabrt: 0x%08x\n", src); jz4780_i2c_txabrt()
544 dev_err(&i2c->adap.dev, "device addr=%x\n", jz4780_i2c_txabrt()
545 jz4780_i2c_readw(i2c, JZ4780_I2C_TAR)); jz4780_i2c_txabrt()
546 dev_err(&i2c->adap.dev, "send cmd count:%d %d\n", jz4780_i2c_txabrt()
547 i2c->cmd, i2c->cmd_buf[i2c->cmd]); jz4780_i2c_txabrt()
548 dev_err(&i2c->adap.dev, "receive data count:%d %d\n", jz4780_i2c_txabrt()
549 i2c->cmd, i2c->data_buf[i2c->cmd]); jz4780_i2c_txabrt()
553 dev_dbg(&i2c->adap.dev, "I2C TXABRT[%d]=%s\n", jz4780_i2c_txabrt()
558 static inline int jz4780_i2c_xfer_read(struct jz4780_i2c *i2c, jz4780_i2c_xfer_read() argument
570 spin_lock_irqsave(&i2c->lock, flags); jz4780_i2c_xfer_read()
572 i2c->stop_hold = 0; jz4780_i2c_xfer_read()
573 i2c->is_write = 0; jz4780_i2c_xfer_read()
574 i2c->rbuf = buf; jz4780_i2c_xfer_read()
575 i2c->rd_total_len = len; jz4780_i2c_xfer_read()
576 i2c->rd_data_xfered = 0; jz4780_i2c_xfer_read()
577 i2c->rd_cmd_xfered = 0; jz4780_i2c_xfer_read()
580 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, len - 1); jz4780_i2c_xfer_read()
582 jz4780_i2c_writew(i2c, JZ4780_I2C_RXTL, RX_LEVEL); jz4780_i2c_xfer_read()
584 jz4780_i2c_writew(i2c, JZ4780_I2C_TXTL, TX_LEVEL); jz4780_i2c_xfer_read()
586 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, jz4780_i2c_xfer_read()
590 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); jz4780_i2c_xfer_read()
592 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_xfer_read()
594 spin_unlock_irqrestore(&i2c->lock, flags); jz4780_i2c_xfer_read()
596 timeout = wait_for_completion_timeout(&i2c->trans_waitq, jz4780_i2c_xfer_read()
600 dev_err(&i2c->adap.dev, "irq read timeout\n"); jz4780_i2c_xfer_read()
601 dev_dbg(&i2c->adap.dev, "send cmd count:%d %d\n", jz4780_i2c_xfer_read()
602 i2c->cmd, i2c->cmd_buf[i2c->cmd]); jz4780_i2c_xfer_read()
603 dev_dbg(&i2c->adap.dev, "receive data count:%d %d\n", jz4780_i2c_xfer_read()
604 i2c->cmd, i2c->data_buf[i2c->cmd]); jz4780_i2c_xfer_read()
608 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_TXABRT); jz4780_i2c_xfer_read()
610 jz4780_i2c_txabrt(i2c, tmp); jz4780_i2c_xfer_read()
617 static inline int jz4780_i2c_xfer_write(struct jz4780_i2c *i2c, jz4780_i2c_xfer_write() argument
627 spin_lock_irqsave(&i2c->lock, flags); jz4780_i2c_xfer_write()
630 i2c->stop_hold = 1; jz4780_i2c_xfer_write()
632 i2c->stop_hold = 0; jz4780_i2c_xfer_write()
634 i2c->is_write = 1; jz4780_i2c_xfer_write()
635 i2c->wbuf = buf; jz4780_i2c_xfer_write()
636 i2c->wt_len = len; jz4780_i2c_xfer_write()
638 jz4780_i2c_writew(i2c, JZ4780_I2C_TXTL, TX_LEVEL); jz4780_i2c_xfer_write()
640 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, JZ4780_I2C_INTM_MTXEMP jz4780_i2c_xfer_write()
643 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); jz4780_i2c_xfer_write()
645 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_xfer_write()
647 spin_unlock_irqrestore(&i2c->lock, flags); jz4780_i2c_xfer_write()
649 timeout = wait_for_completion_timeout(&i2c->trans_waitq, jz4780_i2c_xfer_write()
651 if (timeout && !i2c->stop_hold) { jz4780_i2c_xfer_write()
657 i2c_sta = jz4780_i2c_readw(i2c, JZ4780_I2C_STA); jz4780_i2c_xfer_write()
668 dev_err(&i2c->adap.dev, "write wait timeout\n"); jz4780_i2c_xfer_write()
672 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_TXABRT); jz4780_i2c_xfer_write()
674 jz4780_i2c_txabrt(i2c, tmp); jz4780_i2c_xfer_write()
686 struct jz4780_i2c *i2c = adap->algo_data; jz4780_i2c_xfer() local
688 ret = jz4780_i2c_prepare(i2c); jz4780_i2c_xfer()
690 dev_err(&i2c->adap.dev, "I2C prepare failed\n"); jz4780_i2c_xfer()
694 if (msg->addr != jz4780_i2c_readw(i2c, JZ4780_I2C_TAR)) { jz4780_i2c_xfer()
695 ret = jz4780_i2c_set_target(i2c, msg->addr); jz4780_i2c_xfer()
701 ret = jz4780_i2c_xfer_read(i2c, msg->buf, msg->len, jz4780_i2c_xfer()
704 ret = jz4780_i2c_xfer_write(i2c, msg->buf, msg->len, jz4780_i2c_xfer()
714 jz4780_i2c_cleanup(i2c); jz4780_i2c_xfer()
729 { .compatible = "ingenic,jz4780-i2c", },
739 struct jz4780_i2c *i2c; jz4780_i2c_probe() local
741 i2c = devm_kzalloc(&pdev->dev, sizeof(struct jz4780_i2c), GFP_KERNEL); jz4780_i2c_probe()
742 if (!i2c) jz4780_i2c_probe()
745 i2c->adap.owner = THIS_MODULE; jz4780_i2c_probe()
746 i2c->adap.algo = &jz4780_i2c_algorithm; jz4780_i2c_probe()
747 i2c->adap.algo_data = i2c; jz4780_i2c_probe()
748 i2c->adap.retries = 5; jz4780_i2c_probe()
749 i2c->adap.dev.parent = &pdev->dev; jz4780_i2c_probe()
750 i2c->adap.dev.of_node = pdev->dev.of_node; jz4780_i2c_probe()
751 sprintf(i2c->adap.name, "%s", pdev->name); jz4780_i2c_probe()
753 init_completion(&i2c->trans_waitq); jz4780_i2c_probe()
754 spin_lock_init(&i2c->lock); jz4780_i2c_probe()
757 i2c->iomem = devm_ioremap_resource(&pdev->dev, r); jz4780_i2c_probe()
758 if (IS_ERR(i2c->iomem)) jz4780_i2c_probe()
759 return PTR_ERR(i2c->iomem); jz4780_i2c_probe()
761 platform_set_drvdata(pdev, i2c); jz4780_i2c_probe()
763 i2c->clk = devm_clk_get(&pdev->dev, NULL); jz4780_i2c_probe()
764 if (IS_ERR(i2c->clk)) jz4780_i2c_probe()
765 return PTR_ERR(i2c->clk); jz4780_i2c_probe()
767 ret = clk_prepare_enable(i2c->clk); jz4780_i2c_probe()
778 i2c->speed = clk_freq / 1000; jz4780_i2c_probe()
779 jz4780_i2c_set_speed(i2c); jz4780_i2c_probe()
781 dev_info(&pdev->dev, "Bus frequency is %d KHz\n", i2c->speed); jz4780_i2c_probe()
783 tmp = jz4780_i2c_readw(i2c, JZ4780_I2C_CTRL); jz4780_i2c_probe()
785 jz4780_i2c_writew(i2c, JZ4780_I2C_CTRL, tmp); jz4780_i2c_probe()
787 jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0); jz4780_i2c_probe()
789 i2c->cmd = 0; jz4780_i2c_probe()
790 memset(i2c->cmd_buf, 0, BUFSIZE); jz4780_i2c_probe()
791 memset(i2c->data_buf, 0, BUFSIZE); jz4780_i2c_probe()
793 i2c->irq = platform_get_irq(pdev, 0); jz4780_i2c_probe()
794 ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, jz4780_i2c_probe()
795 dev_name(&pdev->dev), i2c); jz4780_i2c_probe()
799 ret = i2c_add_adapter(&i2c->adap); jz4780_i2c_probe()
808 clk_disable_unprepare(i2c->clk); jz4780_i2c_probe()
814 struct jz4780_i2c *i2c = platform_get_drvdata(pdev); jz4780_i2c_remove() local
816 clk_disable_unprepare(i2c->clk); jz4780_i2c_remove()
817 i2c_del_adapter(&i2c->adap); jz4780_i2c_remove()
825 .name = "jz4780-i2c",
834 MODULE_DESCRIPTION("i2c driver for JZ4780 SoCs");
H A Di2c-kempld.c7 * The driver is based on the i2c-ocores driver by Peter Korsgaard.
21 #include <linux/i2c.h>
90 static int kempld_i2c_process(struct kempld_i2c_data *i2c) kempld_i2c_process() argument
92 struct kempld_device_data *pld = i2c->pld; kempld_i2c_process()
94 struct i2c_msg *msg = i2c->msg; kempld_i2c_process()
101 if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) { kempld_i2c_process()
104 if (i2c->state == STATE_ERROR) kempld_i2c_process()
111 i2c->state = STATE_ERROR; kempld_i2c_process()
116 if (i2c->state == STATE_INIT) { kempld_i2c_process()
120 i2c->state = STATE_ADDR; kempld_i2c_process()
123 if (i2c->state == STATE_ADDR) { kempld_i2c_process()
125 if (i2c->msg->flags & I2C_M_TEN) { kempld_i2c_process()
126 addr = 0xf0 | ((i2c->msg->addr >> 7) & 0x6); kempld_i2c_process()
127 i2c->state = STATE_ADDR10; kempld_i2c_process()
129 addr = (i2c->msg->addr << 1); kempld_i2c_process()
130 i2c->state = STATE_START; kempld_i2c_process()
134 addr |= (i2c->msg->flags & I2C_M_RD) ? 1 : 0; kempld_i2c_process()
143 if (i2c->state == STATE_ADDR10) { kempld_i2c_process()
144 kempld_write8(pld, KEMPLD_I2C_DATA, i2c->msg->addr & 0xff); kempld_i2c_process()
147 i2c->state = STATE_START; kempld_i2c_process()
151 if (i2c->state == STATE_START || i2c->state == STATE_WRITE) { kempld_i2c_process()
152 i2c->state = (msg->flags & I2C_M_RD) ? STATE_READ : STATE_WRITE; kempld_i2c_process()
155 i2c->state = STATE_ERROR; kempld_i2c_process()
160 msg->buf[i2c->pos++] = kempld_read8(pld, KEMPLD_I2C_DATA); kempld_i2c_process()
163 if (i2c->pos >= msg->len) { kempld_i2c_process()
164 i2c->nmsgs--; kempld_i2c_process()
165 i2c->msg++; kempld_i2c_process()
166 i2c->pos = 0; kempld_i2c_process()
167 msg = i2c->msg; kempld_i2c_process()
169 if (i2c->nmsgs) { kempld_i2c_process()
171 i2c->state = STATE_ADDR; kempld_i2c_process()
174 i2c->state = (msg->flags & I2C_M_RD) kempld_i2c_process()
178 i2c->state = STATE_DONE; kempld_i2c_process()
184 if (i2c->state == STATE_READ) { kempld_i2c_process()
185 kempld_write8(pld, KEMPLD_I2C_CMD, i2c->pos == (msg->len - 1) ? kempld_i2c_process()
188 kempld_write8(pld, KEMPLD_I2C_DATA, msg->buf[i2c->pos++]); kempld_i2c_process()
198 struct kempld_i2c_data *i2c = i2c_get_adapdata(adap); kempld_i2c_xfer() local
199 struct kempld_device_data *pld = i2c->pld; kempld_i2c_xfer()
203 i2c->msg = msgs; kempld_i2c_xfer()
204 i2c->pos = 0; kempld_i2c_xfer()
205 i2c->nmsgs = num; kempld_i2c_xfer()
206 i2c->state = STATE_INIT; kempld_i2c_xfer()
211 ret = kempld_i2c_process(i2c); kempld_i2c_xfer()
214 if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) kempld_i2c_xfer()
215 return (i2c->state == STATE_DONE) ? num : ret; kempld_i2c_xfer()
223 i2c->state = STATE_ERROR; kempld_i2c_xfer()
231 static void kempld_i2c_device_init(struct kempld_i2c_data *i2c) kempld_i2c_device_init() argument
233 struct kempld_device_data *pld = i2c->pld; kempld_i2c_device_init()
294 .name = "i2c-kempld",
302 struct kempld_i2c_data *i2c; kempld_i2c_probe() local
306 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); kempld_i2c_probe()
307 if (!i2c) kempld_i2c_probe()
310 i2c->pld = pld; kempld_i2c_probe()
311 i2c->dev = &pdev->dev; kempld_i2c_probe()
312 i2c->adap = kempld_i2c_adapter; kempld_i2c_probe()
313 i2c->adap.dev.parent = i2c->dev; kempld_i2c_probe()
314 i2c_set_adapdata(&i2c->adap, i2c); kempld_i2c_probe()
315 platform_set_drvdata(pdev, i2c); kempld_i2c_probe()
321 i2c->was_active = true; kempld_i2c_probe()
323 kempld_i2c_device_init(i2c); kempld_i2c_probe()
328 i2c->adap.nr = i2c_bus; kempld_i2c_probe()
329 ret = i2c_add_numbered_adapter(&i2c->adap); kempld_i2c_probe()
333 dev_info(i2c->dev, "I2C bus initialized at %dkHz\n", kempld_i2c_probe()
341 struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); kempld_i2c_remove() local
342 struct kempld_device_data *pld = i2c->pld; kempld_i2c_remove()
350 if (!i2c->was_active) { kempld_i2c_remove()
357 i2c_del_adapter(&i2c->adap); kempld_i2c_remove()
365 struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); kempld_i2c_suspend() local
366 struct kempld_device_data *pld = i2c->pld; kempld_i2c_suspend()
380 struct kempld_i2c_data *i2c = platform_get_drvdata(pdev); kempld_i2c_resume() local
381 struct kempld_device_data *pld = i2c->pld; kempld_i2c_resume()
384 kempld_i2c_device_init(i2c); kempld_i2c_resume()
396 .name = "kempld-i2c",
H A Di2c-exynos5.c2 * i2c-exynos5.c - Samsung Exynos5 I2C Controller Driver
14 #include <linux/i2c.h>
249 static void exynos5_i2c_clr_pend_irq(struct exynos5_i2c *i2c) exynos5_i2c_clr_pend_irq() argument
251 writel(readl(i2c->regs + HSI2C_INT_STATUS), exynos5_i2c_clr_pend_irq()
252 i2c->regs + HSI2C_INT_STATUS); exynos5_i2c_clr_pend_irq()
262 static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, int mode) exynos5_i2c_set_timing() argument
274 unsigned int clkin = clk_get_rate(i2c->clk); exynos5_i2c_set_timing()
277 i2c->hs_clock : i2c->fs_clock; exynos5_i2c_set_timing()
291 t_ftl_cycle = (readl(i2c->regs + HSI2C_CONF) >> 16) & 0x7; exynos5_i2c_set_timing()
294 if (i2c->variant->hw == HSI2C_EXYNOS7) exynos5_i2c_set_timing()
312 dev_warn(i2c->dev, "Failed to calculate divisor"); exynos5_i2c_set_timing()
331 dev_dbg(i2c->dev, "tSTART_SU: %X, tSTART_HD: %X, tSTOP_SU: %X\n", exynos5_i2c_set_timing()
333 dev_dbg(i2c->dev, "tDATA_SU: %X, tSCL_L: %X, tSCL_H: %X\n", exynos5_i2c_set_timing()
335 dev_dbg(i2c->dev, "nClkDiv: %X, tSR_RELEASE: %X\n", exynos5_i2c_set_timing()
337 dev_dbg(i2c->dev, "tDATA_HD: %X\n", t_data_hd); exynos5_i2c_set_timing()
340 writel(i2c_timing_s1, i2c->regs + HSI2C_TIMING_HS1); exynos5_i2c_set_timing()
341 writel(i2c_timing_s2, i2c->regs + HSI2C_TIMING_HS2); exynos5_i2c_set_timing()
342 writel(i2c_timing_s3, i2c->regs + HSI2C_TIMING_HS3); exynos5_i2c_set_timing()
344 writel(i2c_timing_s1, i2c->regs + HSI2C_TIMING_FS1); exynos5_i2c_set_timing()
345 writel(i2c_timing_s2, i2c->regs + HSI2C_TIMING_FS2); exynos5_i2c_set_timing()
346 writel(i2c_timing_s3, i2c->regs + HSI2C_TIMING_FS3); exynos5_i2c_set_timing()
348 writel(i2c_timing_sla, i2c->regs + HSI2C_TIMING_SLA); exynos5_i2c_set_timing()
353 static int exynos5_hsi2c_clock_setup(struct exynos5_i2c *i2c) exynos5_hsi2c_clock_setup() argument
359 if (exynos5_i2c_set_timing(i2c, HSI2C_FAST_SPD)) { exynos5_hsi2c_clock_setup()
360 dev_err(i2c->dev, "HSI2C FS Clock set up failed\n"); exynos5_hsi2c_clock_setup()
365 if (i2c->speed_mode == HSI2C_HIGH_SPD) { exynos5_hsi2c_clock_setup()
366 if (exynos5_i2c_set_timing(i2c, HSI2C_HIGH_SPD)) { exynos5_hsi2c_clock_setup()
367 dev_err(i2c->dev, "HSI2C HS Clock set up failed\n"); exynos5_hsi2c_clock_setup()
379 static void exynos5_i2c_init(struct exynos5_i2c *i2c) exynos5_i2c_init() argument
381 u32 i2c_conf = readl(i2c->regs + HSI2C_CONF); exynos5_i2c_init()
382 u32 i2c_timeout = readl(i2c->regs + HSI2C_TIMEOUT); exynos5_i2c_init()
386 writel(i2c_timeout, i2c->regs + HSI2C_TIMEOUT); exynos5_i2c_init()
389 i2c->regs + HSI2C_CTL); exynos5_i2c_init()
390 writel(HSI2C_TRAILING_COUNT, i2c->regs + HSI2C_TRAILIG_CTL); exynos5_i2c_init()
392 if (i2c->speed_mode == HSI2C_HIGH_SPD) { exynos5_i2c_init()
393 writel(HSI2C_MASTER_ID(MASTER_ID(i2c->adap.nr)), exynos5_i2c_init()
394 i2c->regs + HSI2C_ADDR); exynos5_i2c_init()
398 writel(i2c_conf | HSI2C_AUTO_MODE, i2c->regs + HSI2C_CONF); exynos5_i2c_init()
401 static void exynos5_i2c_reset(struct exynos5_i2c *i2c) exynos5_i2c_reset() argument
406 i2c_ctl = readl(i2c->regs + HSI2C_CTL); exynos5_i2c_reset()
408 writel(i2c_ctl, i2c->regs + HSI2C_CTL); exynos5_i2c_reset()
410 i2c_ctl = readl(i2c->regs + HSI2C_CTL); exynos5_i2c_reset()
412 writel(i2c_ctl, i2c->regs + HSI2C_CTL); exynos5_i2c_reset()
415 exynos5_hsi2c_clock_setup(i2c); exynos5_i2c_reset()
417 exynos5_i2c_init(i2c); exynos5_i2c_reset()
429 struct exynos5_i2c *i2c = dev_id; exynos5_i2c_irq() local
434 i2c->state = -EINVAL; exynos5_i2c_irq()
436 spin_lock(&i2c->lock); exynos5_i2c_irq()
438 int_status = readl(i2c->regs + HSI2C_INT_STATUS); exynos5_i2c_irq()
439 writel(int_status, i2c->regs + HSI2C_INT_STATUS); exynos5_i2c_irq()
442 if (i2c->variant->hw == HSI2C_EXYNOS7) { exynos5_i2c_irq()
444 i2c->trans_done = 1; exynos5_i2c_irq()
445 i2c->state = 0; exynos5_i2c_irq()
447 dev_dbg(i2c->dev, "Deal with arbitration lose\n"); exynos5_i2c_irq()
448 i2c->state = -EAGAIN; exynos5_i2c_irq()
451 dev_dbg(i2c->dev, "No ACK from device\n"); exynos5_i2c_irq()
452 i2c->state = -ENXIO; exynos5_i2c_irq()
455 dev_dbg(i2c->dev, "No device\n"); exynos5_i2c_irq()
456 i2c->state = -ENXIO; exynos5_i2c_irq()
459 dev_dbg(i2c->dev, "Accessing device timed out\n"); exynos5_i2c_irq()
460 i2c->state = -ETIMEDOUT; exynos5_i2c_irq()
464 trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); exynos5_i2c_irq()
466 dev_dbg(i2c->dev, "No ACK from device\n"); exynos5_i2c_irq()
467 i2c->state = -ENXIO; exynos5_i2c_irq()
470 dev_dbg(i2c->dev, "No device\n"); exynos5_i2c_irq()
471 i2c->state = -ENXIO; exynos5_i2c_irq()
474 dev_dbg(i2c->dev, "Deal with arbitration lose\n"); exynos5_i2c_irq()
475 i2c->state = -EAGAIN; exynos5_i2c_irq()
478 dev_dbg(i2c->dev, "Accessing device timed out\n"); exynos5_i2c_irq()
479 i2c->state = -ETIMEDOUT; exynos5_i2c_irq()
482 i2c->trans_done = 1; exynos5_i2c_irq()
483 i2c->state = 0; exynos5_i2c_irq()
487 if ((i2c->msg->flags & I2C_M_RD) && (int_status & exynos5_i2c_irq()
489 fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); exynos5_i2c_irq()
491 len = min(fifo_level, i2c->msg->len - i2c->msg_ptr); exynos5_i2c_irq()
495 readl(i2c->regs + HSI2C_RX_DATA); exynos5_i2c_irq()
496 i2c->msg->buf[i2c->msg_ptr++] = byte; exynos5_i2c_irq()
499 i2c->state = 0; exynos5_i2c_irq()
501 fifo_status = readl(i2c->regs + HSI2C_FIFO_STATUS); exynos5_i2c_irq()
504 len = i2c->variant->fifo_depth - fifo_level; exynos5_i2c_irq()
505 if (len > (i2c->msg->len - i2c->msg_ptr)) exynos5_i2c_irq()
506 len = i2c->msg->len - i2c->msg_ptr; exynos5_i2c_irq()
509 byte = i2c->msg->buf[i2c->msg_ptr++]; exynos5_i2c_irq()
510 writel(byte, i2c->regs + HSI2C_TX_DATA); exynos5_i2c_irq()
513 i2c->state = 0; exynos5_i2c_irq()
517 if ((i2c->trans_done && (i2c->msg->len == i2c->msg_ptr)) || exynos5_i2c_irq()
518 (i2c->state < 0)) { exynos5_i2c_irq()
519 writel(0, i2c->regs + HSI2C_INT_ENABLE); exynos5_i2c_irq()
520 exynos5_i2c_clr_pend_irq(i2c); exynos5_i2c_irq()
521 complete(&i2c->msg_complete); exynos5_i2c_irq()
524 spin_unlock(&i2c->lock); exynos5_i2c_irq()
537 static int exynos5_i2c_wait_bus_idle(struct exynos5_i2c *i2c) exynos5_i2c_wait_bus_idle() argument
545 trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); exynos5_i2c_wait_bus_idle()
557 * i2c: struct exynos5_i2c pointer for the current bus
565 static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop) exynos5_i2c_message_start() argument
574 if (i2c->variant->hw == HSI2C_EXYNOS7) exynos5_i2c_message_start()
579 i2c_ctl = readl(i2c->regs + HSI2C_CTL); exynos5_i2c_message_start()
583 if (i2c->msg->flags & I2C_M_RD) { exynos5_i2c_message_start()
588 trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? exynos5_i2c_message_start()
589 (i2c->variant->fifo_depth * 3 / 4) : i2c->msg->len; exynos5_i2c_message_start()
597 trig_lvl = (i2c->msg->len > i2c->variant->fifo_depth) ? exynos5_i2c_message_start()
598 (i2c->variant->fifo_depth * 1 / 4) : i2c->msg->len; exynos5_i2c_message_start()
604 writel(HSI2C_SLV_ADDR_MAS(i2c->msg->addr), i2c->regs + HSI2C_ADDR); exynos5_i2c_message_start()
606 writel(fifo_ctl, i2c->regs + HSI2C_FIFO_CTL); exynos5_i2c_message_start()
607 writel(i2c_ctl, i2c->regs + HSI2C_CTL); exynos5_i2c_message_start()
613 spin_lock_irqsave(&i2c->lock, flags); exynos5_i2c_message_start()
614 writel(int_en, i2c->regs + HSI2C_INT_ENABLE); exynos5_i2c_message_start()
618 i2c_auto_conf |= i2c->msg->len; exynos5_i2c_message_start()
620 writel(i2c_auto_conf, i2c->regs + HSI2C_AUTO_CONF); exynos5_i2c_message_start()
621 spin_unlock_irqrestore(&i2c->lock, flags); exynos5_i2c_message_start()
624 static int exynos5_i2c_xfer_msg(struct exynos5_i2c *i2c, exynos5_i2c_xfer_msg() argument
630 i2c->msg = msgs; exynos5_i2c_xfer_msg()
631 i2c->msg_ptr = 0; exynos5_i2c_xfer_msg()
632 i2c->trans_done = 0; exynos5_i2c_xfer_msg()
634 reinit_completion(&i2c->msg_complete); exynos5_i2c_xfer_msg()
636 exynos5_i2c_message_start(i2c, stop); exynos5_i2c_xfer_msg()
638 timeout = wait_for_completion_timeout(&i2c->msg_complete, exynos5_i2c_xfer_msg()
643 ret = i2c->state; exynos5_i2c_xfer_msg()
650 ret = exynos5_i2c_wait_bus_idle(i2c); exynos5_i2c_xfer_msg()
653 exynos5_i2c_reset(i2c); exynos5_i2c_xfer_msg()
655 dev_warn(i2c->dev, "%s timeout\n", exynos5_i2c_xfer_msg()
666 struct exynos5_i2c *i2c = adap->algo_data; exynos5_i2c_xfer() local
669 if (i2c->suspended) { exynos5_i2c_xfer()
670 dev_err(i2c->dev, "HS-I2C is not initialized.\n"); exynos5_i2c_xfer()
674 ret = clk_enable(i2c->clk); exynos5_i2c_xfer()
681 ret = exynos5_i2c_xfer_msg(i2c, msgs, stop); exynos5_i2c_xfer()
696 dev_warn(i2c->dev, "xfer message failed\n"); exynos5_i2c_xfer()
700 clk_disable(i2c->clk); exynos5_i2c_xfer()
717 struct exynos5_i2c *i2c; exynos5_i2c_probe() local
722 i2c = devm_kzalloc(&pdev->dev, sizeof(struct exynos5_i2c), GFP_KERNEL); exynos5_i2c_probe()
723 if (!i2c) exynos5_i2c_probe()
727 i2c->speed_mode = HSI2C_FAST_SPD; exynos5_i2c_probe()
728 i2c->fs_clock = HSI2C_FS_TX_CLOCK; exynos5_i2c_probe()
731 i2c->speed_mode = HSI2C_HIGH_SPD; exynos5_i2c_probe()
732 i2c->fs_clock = HSI2C_FS_TX_CLOCK; exynos5_i2c_probe()
733 i2c->hs_clock = op_clock; exynos5_i2c_probe()
735 i2c->speed_mode = HSI2C_FAST_SPD; exynos5_i2c_probe()
736 i2c->fs_clock = op_clock; exynos5_i2c_probe()
740 strlcpy(i2c->adap.name, "exynos5-i2c", sizeof(i2c->adap.name)); exynos5_i2c_probe()
741 i2c->adap.owner = THIS_MODULE; exynos5_i2c_probe()
742 i2c->adap.algo = &exynos5_i2c_algorithm; exynos5_i2c_probe()
743 i2c->adap.retries = 3; exynos5_i2c_probe()
745 i2c->dev = &pdev->dev; exynos5_i2c_probe()
746 i2c->clk = devm_clk_get(&pdev->dev, "hsi2c"); exynos5_i2c_probe()
747 if (IS_ERR(i2c->clk)) { exynos5_i2c_probe()
752 ret = clk_prepare_enable(i2c->clk); exynos5_i2c_probe()
757 i2c->regs = devm_ioremap_resource(&pdev->dev, mem); exynos5_i2c_probe()
758 if (IS_ERR(i2c->regs)) { exynos5_i2c_probe()
759 ret = PTR_ERR(i2c->regs); exynos5_i2c_probe()
763 i2c->adap.dev.of_node = np; exynos5_i2c_probe()
764 i2c->adap.algo_data = i2c; exynos5_i2c_probe()
765 i2c->adap.dev.parent = &pdev->dev; exynos5_i2c_probe()
768 exynos5_i2c_clr_pend_irq(i2c); exynos5_i2c_probe()
770 spin_lock_init(&i2c->lock); exynos5_i2c_probe()
771 init_completion(&i2c->msg_complete); exynos5_i2c_probe()
773 i2c->irq = ret = platform_get_irq(pdev, 0); exynos5_i2c_probe()
780 ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq, exynos5_i2c_probe()
782 dev_name(&pdev->dev), i2c); exynos5_i2c_probe()
785 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", i2c->irq); exynos5_i2c_probe()
790 i2c->variant = exynos5_i2c_get_variant(pdev); exynos5_i2c_probe()
792 ret = exynos5_hsi2c_clock_setup(i2c); exynos5_i2c_probe()
796 exynos5_i2c_reset(i2c); exynos5_i2c_probe()
798 ret = i2c_add_adapter(&i2c->adap); exynos5_i2c_probe()
800 dev_err(&pdev->dev, "failed to add bus to i2c core\n"); exynos5_i2c_probe()
804 platform_set_drvdata(pdev, i2c); exynos5_i2c_probe()
806 clk_disable(i2c->clk); exynos5_i2c_probe()
811 clk_disable_unprepare(i2c->clk); exynos5_i2c_probe()
817 struct exynos5_i2c *i2c = platform_get_drvdata(pdev); exynos5_i2c_remove() local
819 i2c_del_adapter(&i2c->adap); exynos5_i2c_remove()
821 clk_unprepare(i2c->clk); exynos5_i2c_remove()
830 struct exynos5_i2c *i2c = platform_get_drvdata(pdev); exynos5_i2c_suspend_noirq() local
832 i2c->suspended = 1; exynos5_i2c_suspend_noirq()
834 clk_unprepare(i2c->clk); exynos5_i2c_suspend_noirq()
842 struct exynos5_i2c *i2c = platform_get_drvdata(pdev); exynos5_i2c_resume_noirq() local
845 ret = clk_prepare_enable(i2c->clk); exynos5_i2c_resume_noirq()
849 ret = exynos5_hsi2c_clock_setup(i2c); exynos5_i2c_resume_noirq()
851 clk_disable_unprepare(i2c->clk); exynos5_i2c_resume_noirq()
855 exynos5_i2c_init(i2c); exynos5_i2c_resume_noirq()
856 clk_disable(i2c->clk); exynos5_i2c_resume_noirq()
857 i2c->suspended = 0; exynos5_i2c_resume_noirq()
H A Di2c-lpc2k.c4 * Code portions referenced from the i2x-pxa and i2c-pnx drivers
22 #include <linux/i2c.h>
89 static void i2c_lpc2k_reset(struct lpc2k_i2c *i2c) i2c_lpc2k_reset() argument
92 writel(LPC24XX_CLEAR_ALL, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_reset()
93 writel(0, i2c->base + LPC24XX_I2ADDR); i2c_lpc2k_reset()
94 writel(LPC24XX_I2EN, i2c->base + LPC24XX_I2CONSET); i2c_lpc2k_reset()
97 static int i2c_lpc2k_clear_arb(struct lpc2k_i2c *i2c) i2c_lpc2k_clear_arb() argument
105 writel(LPC24XX_STO, i2c->base + LPC24XX_I2CONSET); i2c_lpc2k_clear_arb()
108 while (readl(i2c->base + LPC24XX_I2STAT) != M_I2C_IDLE) { i2c_lpc2k_clear_arb()
111 i2c_lpc2k_reset(i2c); i2c_lpc2k_clear_arb()
121 static void i2c_lpc2k_pump_msg(struct lpc2k_i2c *i2c) i2c_lpc2k_pump_msg() argument
130 status = readl(i2c->base + LPC24XX_I2STAT); i2c_lpc2k_pump_msg()
136 data = i2c->msg->addr << 1; i2c_lpc2k_pump_msg()
137 if (i2c->msg->flags & I2C_M_RD) i2c_lpc2k_pump_msg()
140 writel(data, i2c->base + LPC24XX_I2DAT); i2c_lpc2k_pump_msg()
141 writel(LPC24XX_STA, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
150 if (i2c->msg_idx < i2c->msg->len) { i2c_lpc2k_pump_msg()
151 writel(i2c->msg->buf[i2c->msg_idx], i2c_lpc2k_pump_msg()
152 i2c->base + LPC24XX_I2DAT); i2c_lpc2k_pump_msg()
153 } else if (i2c->is_last) { i2c_lpc2k_pump_msg()
155 writel(LPC24XX_STO_AA, i2c->base + LPC24XX_I2CONSET); i2c_lpc2k_pump_msg()
156 writel(LPC24XX_SI, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
157 i2c->msg_status = 0; i2c_lpc2k_pump_msg()
158 disable_irq_nosync(i2c->irq); i2c_lpc2k_pump_msg()
160 i2c->msg_status = 0; i2c_lpc2k_pump_msg()
161 disable_irq_nosync(i2c->irq); i2c_lpc2k_pump_msg()
164 i2c->msg_idx++; i2c_lpc2k_pump_msg()
169 if (i2c->msg->len == 1) { i2c_lpc2k_pump_msg()
171 writel(LPC24XX_AA, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
174 writel(LPC24XX_AA, i2c->base + LPC24XX_I2CONSET); i2c_lpc2k_pump_msg()
177 writel(LPC24XX_STA, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
188 if (i2c->msg_idx < i2c->msg->len) { i2c_lpc2k_pump_msg()
189 i2c->msg->buf[i2c->msg_idx] = i2c_lpc2k_pump_msg()
190 readl(i2c->base + LPC24XX_I2DAT); i2c_lpc2k_pump_msg()
194 if (i2c->msg_idx >= i2c->msg->len - 1 && i2c->is_last) { i2c_lpc2k_pump_msg()
195 writel(LPC24XX_STO_AA, i2c->base + LPC24XX_I2CONSET); i2c_lpc2k_pump_msg()
196 writel(LPC24XX_SI, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
197 i2c->msg_status = 0; i2c_lpc2k_pump_msg()
201 if (i2c->msg_idx >= i2c->msg->len - 1) { i2c_lpc2k_pump_msg()
202 i2c->msg_status = 0; i2c_lpc2k_pump_msg()
203 disable_irq_nosync(i2c->irq); i2c_lpc2k_pump_msg()
210 if (i2c->msg_idx >= i2c->msg->len - 2) { i2c_lpc2k_pump_msg()
212 writel(LPC24XX_AA, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
215 writel(LPC24XX_AA, i2c->base + LPC24XX_I2CONSET); i2c_lpc2k_pump_msg()
218 writel(LPC24XX_STA, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
219 i2c->msg_idx++; i2c_lpc2k_pump_msg()
226 writel(LPC24XX_STO_AA, i2c->base + LPC24XX_I2CONSET); i2c_lpc2k_pump_msg()
227 i2c->msg_status = -ENXIO; i2c_lpc2k_pump_msg()
228 disable_irq_nosync(i2c->irq); i2c_lpc2k_pump_msg()
233 i2c->msg_status = -EAGAIN; i2c_lpc2k_pump_msg()
236 writel(LPC24XX_STA | LPC24XX_STO, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
237 disable_irq_nosync(i2c->irq); i2c_lpc2k_pump_msg()
242 i2c->msg_status = -EIO; i2c_lpc2k_pump_msg()
243 disable_irq_nosync(i2c->irq); i2c_lpc2k_pump_msg()
248 if (i2c->msg_status != -EBUSY) i2c_lpc2k_pump_msg()
249 wake_up(&i2c->wait); i2c_lpc2k_pump_msg()
255 if (i2c->msg_status != 0) i2c_lpc2k_pump_msg()
256 writel(LPC24XX_SI, i2c->base + LPC24XX_I2CONCLR); i2c_lpc2k_pump_msg()
259 static int lpc2k_process_msg(struct lpc2k_i2c *i2c, int msgidx) lpc2k_process_msg() argument
263 writel(LPC24XX_STA, i2c->base + LPC24XX_I2CONSET); lpc2k_process_msg()
270 if (unlikely(i2c->msg->flags & I2C_M_NOSTART)) { lpc2k_process_msg()
271 WARN_ON(i2c->msg->len == 0); lpc2k_process_msg()
273 if (!(i2c->msg->flags & I2C_M_RD)) { lpc2k_process_msg()
275 writel(i2c->msg->buf[0], lpc2k_process_msg()
276 i2c->base + LPC24XX_I2DAT); lpc2k_process_msg()
277 i2c->msg_idx++; lpc2k_process_msg()
281 writel(LPC24XX_STA, i2c->base + LPC24XX_I2CONSET); lpc2k_process_msg()
284 writel(LPC24XX_SI, i2c->base + LPC24XX_I2CONCLR); lpc2k_process_msg()
287 enable_irq(i2c->irq); lpc2k_process_msg()
290 if (wait_event_timeout(i2c->wait, i2c->msg_status != -EBUSY, lpc2k_process_msg()
292 disable_irq_nosync(i2c->irq); lpc2k_process_msg()
297 return i2c->msg_status; lpc2k_process_msg()
303 struct lpc2k_i2c *i2c = i2c_get_adapdata(adap); i2c_lpc2k_xfer() local
308 stat = readl(i2c->base + LPC24XX_I2STAT); i2c_lpc2k_xfer()
311 return i2c_lpc2k_clear_arb(i2c); i2c_lpc2k_xfer()
317 i2c->msg = &msgs[i]; i2c_lpc2k_xfer()
318 i2c->msg_idx = 0; i2c_lpc2k_xfer()
319 i2c->msg_status = -EBUSY; i2c_lpc2k_xfer()
320 i2c->is_last = (i == (msg_num - 1)); i2c_lpc2k_xfer()
322 ret = lpc2k_process_msg(i2c, i); i2c_lpc2k_xfer()
332 struct lpc2k_i2c *i2c = dev_id; i2c_lpc2k_handler() local
334 if (readl(i2c->base + LPC24XX_I2CONSET) & LPC24XX_SI) { i2c_lpc2k_handler()
335 i2c_lpc2k_pump_msg(i2c); i2c_lpc2k_handler()
355 struct lpc2k_i2c *i2c; i2c_lpc2k_probe() local
362 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); i2c_lpc2k_probe()
363 if (!i2c) i2c_lpc2k_probe()
367 i2c->base = devm_ioremap_resource(&pdev->dev, res); i2c_lpc2k_probe()
368 if (IS_ERR(i2c->base)) i2c_lpc2k_probe()
369 return PTR_ERR(i2c->base); i2c_lpc2k_probe()
371 i2c->irq = platform_get_irq(pdev, 0); i2c_lpc2k_probe()
372 if (i2c->irq < 0) { i2c_lpc2k_probe()
374 return i2c->irq; i2c_lpc2k_probe()
377 init_waitqueue_head(&i2c->wait); i2c_lpc2k_probe()
379 i2c->clk = devm_clk_get(&pdev->dev, NULL); i2c_lpc2k_probe()
380 if (IS_ERR(i2c->clk)) { i2c_lpc2k_probe()
382 return PTR_ERR(i2c->clk); i2c_lpc2k_probe()
385 ret = clk_prepare_enable(i2c->clk); i2c_lpc2k_probe()
391 ret = devm_request_irq(&pdev->dev, i2c->irq, i2c_lpc2k_handler, 0, i2c_lpc2k_probe()
392 dev_name(&pdev->dev), i2c); i2c_lpc2k_probe()
398 disable_irq_nosync(i2c->irq); i2c_lpc2k_probe()
401 i2c_lpc2k_reset(i2c); i2c_lpc2k_probe()
408 clkrate = clk_get_rate(i2c->clk); i2c_lpc2k_probe()
424 writel(scl_high, i2c->base + LPC24XX_I2SCLH); i2c_lpc2k_probe()
425 writel(clkrate - scl_high, i2c->base + LPC24XX_I2SCLL); i2c_lpc2k_probe()
427 platform_set_drvdata(pdev, i2c); i2c_lpc2k_probe()
429 i2c_set_adapdata(&i2c->adap, i2c); i2c_lpc2k_probe()
430 i2c->adap.owner = THIS_MODULE; i2c_lpc2k_probe()
431 strlcpy(i2c->adap.name, "LPC2K I2C adapter", sizeof(i2c->adap.name)); i2c_lpc2k_probe()
432 i2c->adap.algo = &i2c_lpc2k_algorithm; i2c_lpc2k_probe()
433 i2c->adap.dev.parent = &pdev->dev; i2c_lpc2k_probe()
434 i2c->adap.dev.of_node = pdev->dev.of_node; i2c_lpc2k_probe()
436 ret = i2c_add_adapter(&i2c->adap); i2c_lpc2k_probe()
447 clk_disable_unprepare(i2c->clk); i2c_lpc2k_probe()
453 struct lpc2k_i2c *i2c = platform_get_drvdata(dev); i2c_lpc2k_remove() local
455 i2c_del_adapter(&i2c->adap); i2c_lpc2k_remove()
456 clk_disable_unprepare(i2c->clk); i2c_lpc2k_remove()
465 struct lpc2k_i2c *i2c = platform_get_drvdata(pdev); i2c_lpc2k_suspend() local
467 clk_disable(i2c->clk); i2c_lpc2k_suspend()
475 struct lpc2k_i2c *i2c = platform_get_drvdata(pdev); i2c_lpc2k_resume() local
477 clk_enable(i2c->clk); i2c_lpc2k_resume()
478 i2c_lpc2k_reset(i2c); i2c_lpc2k_resume()
494 { .compatible = "nxp,lpc1788-i2c" },
503 .name = "lpc2k-i2c",
513 MODULE_ALIAS("platform:lpc2k-i2c");
H A Di2c-octeon.c7 * This is a driver for the i2c adapter in Cavium Networks' OCTEON processors.
21 #include <linux/i2c.h>
27 #define DRV_NAME "i2c-octeon"
77 * @i2c: The struct octeon_i2c.
83 static void octeon_i2c_write_sw(struct octeon_i2c *i2c, octeon_i2c_write_sw() argument
89 __raw_writeq(SW_TWSI_V | eop_reg | data, i2c->twsi_base + SW_TWSI); octeon_i2c_write_sw()
91 tmp = __raw_readq(i2c->twsi_base + SW_TWSI); octeon_i2c_write_sw()
97 * @i2c: The struct octeon_i2c.
104 static u8 octeon_i2c_read_sw(struct octeon_i2c *i2c, u64 eop_reg) octeon_i2c_read_sw() argument
108 __raw_writeq(SW_TWSI_V | eop_reg | SW_TWSI_R, i2c->twsi_base + SW_TWSI); octeon_i2c_read_sw()
110 tmp = __raw_readq(i2c->twsi_base + SW_TWSI); octeon_i2c_read_sw()
118 * @i2c: The struct octeon_i2c.
121 static void octeon_i2c_write_int(struct octeon_i2c *i2c, u64 data) octeon_i2c_write_int() argument
123 __raw_writeq(data, i2c->twsi_base + TWSI_INT); octeon_i2c_write_int()
124 __raw_readq(i2c->twsi_base + TWSI_INT); octeon_i2c_write_int()
129 * @i2c: The struct octeon_i2c.
134 static void octeon_i2c_int_enable(struct octeon_i2c *i2c) octeon_i2c_int_enable() argument
136 octeon_i2c_write_int(i2c, 0x40); octeon_i2c_int_enable()
141 * @i2c: The struct octeon_i2c.
143 static void octeon_i2c_int_disable(struct octeon_i2c *i2c) octeon_i2c_int_disable() argument
145 octeon_i2c_write_int(i2c, 0); octeon_i2c_int_disable()
150 * @i2c: The struct octeon_i2c.
156 static void octeon_i2c_unblock(struct octeon_i2c *i2c) octeon_i2c_unblock() argument
160 dev_dbg(i2c->dev, "%s\n", __func__); octeon_i2c_unblock()
162 octeon_i2c_write_int(i2c, 0x0); octeon_i2c_unblock()
164 octeon_i2c_write_int(i2c, 0x200); octeon_i2c_unblock()
167 octeon_i2c_write_int(i2c, 0x300); octeon_i2c_unblock()
169 octeon_i2c_write_int(i2c, 0x100); octeon_i2c_unblock()
171 octeon_i2c_write_int(i2c, 0x0); octeon_i2c_unblock()
181 struct octeon_i2c *i2c = dev_id; octeon_i2c_isr() local
183 octeon_i2c_int_disable(i2c); octeon_i2c_isr()
184 wake_up(&i2c->queue); octeon_i2c_isr()
190 static int octeon_i2c_test_iflg(struct octeon_i2c *i2c) octeon_i2c_test_iflg() argument
192 return (octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_CTL) & TWSI_CTL_IFLG) != 0; octeon_i2c_test_iflg()
197 * @i2c: The struct octeon_i2c.
201 static int octeon_i2c_wait(struct octeon_i2c *i2c) octeon_i2c_wait() argument
205 octeon_i2c_int_enable(i2c); octeon_i2c_wait()
207 result = wait_event_timeout(i2c->queue, octeon_i2c_wait()
208 octeon_i2c_test_iflg(i2c), octeon_i2c_wait()
209 i2c->adap.timeout); octeon_i2c_wait()
211 octeon_i2c_int_disable(i2c); octeon_i2c_wait()
214 dev_dbg(i2c->dev, "%s: timeout\n", __func__); octeon_i2c_wait()
223 * @i2c: The struct octeon_i2c.
227 static int octeon_i2c_start(struct octeon_i2c *i2c) octeon_i2c_start() argument
232 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, octeon_i2c_start()
235 result = octeon_i2c_wait(i2c); octeon_i2c_start()
237 if (octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT) == STAT_IDLE) { octeon_i2c_start()
243 octeon_i2c_unblock(i2c); octeon_i2c_start()
244 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, octeon_i2c_start()
247 result = octeon_i2c_wait(i2c); octeon_i2c_start()
253 data = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT); octeon_i2c_start()
255 dev_err(i2c->dev, "%s: bad status (0x%x)\n", __func__, data); octeon_i2c_start()
264 * @i2c: The struct octeon_i2c.
268 static int octeon_i2c_stop(struct octeon_i2c *i2c) octeon_i2c_stop() argument
272 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, octeon_i2c_stop()
275 data = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT); octeon_i2c_stop()
278 dev_err(i2c->dev, "%s: bad status(0x%x)\n", __func__, data); octeon_i2c_stop()
286 * @i2c: The struct octeon_i2c.
295 static int octeon_i2c_write(struct octeon_i2c *i2c, int target, octeon_i2c_write() argument
301 result = octeon_i2c_start(i2c); octeon_i2c_write()
305 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, target << 1); octeon_i2c_write()
306 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); octeon_i2c_write()
308 result = octeon_i2c_wait(i2c); octeon_i2c_write()
313 tmp = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT); octeon_i2c_write()
315 dev_err(i2c->dev, octeon_i2c_write()
321 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, data[i]); octeon_i2c_write()
322 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); octeon_i2c_write()
324 result = octeon_i2c_wait(i2c); octeon_i2c_write()
334 * @i2c: The struct octeon_i2c.
343 static int octeon_i2c_read(struct octeon_i2c *i2c, int target, octeon_i2c_read() argument
352 result = octeon_i2c_start(i2c); octeon_i2c_read()
356 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_DATA, (target<<1) | 1); octeon_i2c_read()
357 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); octeon_i2c_read()
359 result = octeon_i2c_wait(i2c); octeon_i2c_read()
364 tmp = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT); octeon_i2c_read()
366 dev_err(i2c->dev, octeon_i2c_read()
373 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, octeon_i2c_read()
376 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, octeon_i2c_read()
379 result = octeon_i2c_wait(i2c); octeon_i2c_read()
383 data[i] = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_DATA); octeon_i2c_read()
404 struct octeon_i2c *i2c = i2c_get_adapdata(adap); octeon_i2c_xfer() local
408 dev_dbg(i2c->dev, octeon_i2c_xfer()
413 ret = octeon_i2c_read(i2c, pmsg->addr, pmsg->buf, octeon_i2c_xfer()
416 ret = octeon_i2c_write(i2c, pmsg->addr, pmsg->buf, octeon_i2c_xfer()
419 octeon_i2c_stop(i2c); octeon_i2c_xfer()
444 static int octeon_i2c_setclock(struct octeon_i2c *i2c) octeon_i2c_setclock() argument
460 tclk = i2c->twsi_freq * (mdiv_idx + 1) * 10; octeon_i2c_setclock()
462 thp_base = (i2c->sys_freq / (tclk * 2)) - 1; octeon_i2c_setclock()
468 foscl = i2c->sys_freq / (2 * (thp_idx + 1)); octeon_i2c_setclock()
471 diff = abs(foscl - i2c->twsi_freq); octeon_i2c_setclock()
481 octeon_i2c_write_sw(i2c, SW_TWSI_OP_TWSI_CLK, thp); octeon_i2c_setclock()
482 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CLKCTL, (mdiv << 3) | ndiv); octeon_i2c_setclock()
487 static int octeon_i2c_initlowlevel(struct octeon_i2c *i2c) octeon_i2c_initlowlevel() argument
493 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_CTL, TWSI_CTL_ENAB); octeon_i2c_initlowlevel()
496 octeon_i2c_write_sw(i2c, SW_TWSI_EOP_TWSI_RST, 0); octeon_i2c_initlowlevel()
500 status = octeon_i2c_read_sw(i2c, SW_TWSI_EOP_TWSI_STAT); octeon_i2c_initlowlevel()
504 dev_err(i2c->dev, "%s: TWSI_RST failed! (0x%x)\n", __func__, status); octeon_i2c_initlowlevel()
511 struct octeon_i2c *i2c; octeon_i2c_probe() local
519 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); octeon_i2c_probe()
520 if (!i2c) { octeon_i2c_probe()
525 i2c->dev = &pdev->dev; octeon_i2c_probe()
530 dev_err(i2c->dev, "found no memory resource\n"); octeon_i2c_probe()
534 i2c->twsi_phys = res_mem->start; octeon_i2c_probe()
535 i2c->regsize = resource_size(res_mem); octeon_i2c_probe()
543 "clock-frequency", &i2c->twsi_freq) && octeon_i2c_probe()
545 "clock-rate", &i2c->twsi_freq)) { octeon_i2c_probe()
546 dev_err(i2c->dev, octeon_i2c_probe()
552 i2c->sys_freq = octeon_get_io_clock_rate(); octeon_i2c_probe()
554 if (!devm_request_mem_region(&pdev->dev, i2c->twsi_phys, i2c->regsize, octeon_i2c_probe()
556 dev_err(i2c->dev, "request_mem_region failed\n"); octeon_i2c_probe()
559 i2c->twsi_base = devm_ioremap(&pdev->dev, i2c->twsi_phys, i2c->regsize); octeon_i2c_probe()
561 init_waitqueue_head(&i2c->queue); octeon_i2c_probe()
563 i2c->irq = irq; octeon_i2c_probe()
565 result = devm_request_irq(&pdev->dev, i2c->irq, octeon_i2c_probe()
566 octeon_i2c_isr, 0, DRV_NAME, i2c); octeon_i2c_probe()
568 dev_err(i2c->dev, "failed to attach interrupt\n"); octeon_i2c_probe()
572 result = octeon_i2c_initlowlevel(i2c); octeon_i2c_probe()
574 dev_err(i2c->dev, "init low level failed\n"); octeon_i2c_probe()
578 result = octeon_i2c_setclock(i2c); octeon_i2c_probe()
580 dev_err(i2c->dev, "clock init failed\n"); octeon_i2c_probe()
584 i2c->adap = octeon_i2c_ops; octeon_i2c_probe()
585 i2c->adap.dev.parent = &pdev->dev; octeon_i2c_probe()
586 i2c->adap.dev.of_node = pdev->dev.of_node; octeon_i2c_probe()
587 i2c_set_adapdata(&i2c->adap, i2c); octeon_i2c_probe()
588 platform_set_drvdata(pdev, i2c); octeon_i2c_probe()
590 result = i2c_add_adapter(&i2c->adap); octeon_i2c_probe()
592 dev_err(i2c->dev, "failed to add adapter\n"); octeon_i2c_probe()
595 dev_info(i2c->dev, "version %s\n", DRV_VERSION); octeon_i2c_probe()
605 struct octeon_i2c *i2c = platform_get_drvdata(pdev); octeon_i2c_remove() local
607 i2c_del_adapter(&i2c->adap); octeon_i2c_remove()
H A Di2c-mt65xx.c22 #include <linux/i2c.h>
79 #define I2C_DRV_NAME "i2c-mt65xx"
138 struct i2c_adapter adap; /* i2c host adapter */
142 /* set in i2c probe */
143 void __iomem *base; /* i2c base addr */
145 struct clk *clk_main; /* main clock for i2c bus */
146 struct clk *clk_dma; /* DMA clock for i2c via DMA */
147 struct clk *clk_pmic; /* PMIC clock for i2c from PMIC */
148 bool have_pmic; /* can use i2c pins from PMIC */
198 { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat },
199 { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat },
200 { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat },
205 static int mtk_i2c_clock_enable(struct mtk_i2c *i2c) mtk_i2c_clock_enable() argument
209 ret = clk_prepare_enable(i2c->clk_dma); mtk_i2c_clock_enable()
213 ret = clk_prepare_enable(i2c->clk_main); mtk_i2c_clock_enable()
217 if (i2c->have_pmic) { mtk_i2c_clock_enable()
218 ret = clk_prepare_enable(i2c->clk_pmic); mtk_i2c_clock_enable()
225 clk_disable_unprepare(i2c->clk_main); mtk_i2c_clock_enable()
227 clk_disable_unprepare(i2c->clk_dma); mtk_i2c_clock_enable()
232 static void mtk_i2c_clock_disable(struct mtk_i2c *i2c) mtk_i2c_clock_disable() argument
234 if (i2c->have_pmic) mtk_i2c_clock_disable()
235 clk_disable_unprepare(i2c->clk_pmic); mtk_i2c_clock_disable()
237 clk_disable_unprepare(i2c->clk_main); mtk_i2c_clock_disable()
238 clk_disable_unprepare(i2c->clk_dma); mtk_i2c_clock_disable()
241 static void mtk_i2c_init_hw(struct mtk_i2c *i2c) mtk_i2c_init_hw() argument
245 writew(I2C_SOFT_RST, i2c->base + OFFSET_SOFTRESET); mtk_i2c_init_hw()
248 if (i2c->use_push_pull) mtk_i2c_init_hw()
249 writew(I2C_IO_CONFIG_PUSH_PULL, i2c->base + OFFSET_IO_CONFIG); mtk_i2c_init_hw()
251 writew(I2C_IO_CONFIG_OPEN_DRAIN, i2c->base + OFFSET_IO_CONFIG); mtk_i2c_init_hw()
253 if (i2c->dev_comp->dcm) mtk_i2c_init_hw()
254 writew(I2C_DCM_DISABLE, i2c->base + OFFSET_DCM_EN); mtk_i2c_init_hw()
256 writew(i2c->timing_reg, i2c->base + OFFSET_TIMING); mtk_i2c_init_hw()
257 writew(i2c->high_speed_reg, i2c->base + OFFSET_HS); mtk_i2c_init_hw()
259 /* If use i2c pin from PMIC mt6397 side, need set PATH_DIR first */ mtk_i2c_init_hw()
260 if (i2c->have_pmic) mtk_i2c_init_hw()
261 writew(I2C_CONTROL_WRAPPER, i2c->base + OFFSET_PATH_DIR); mtk_i2c_init_hw()
265 writew(control_reg, i2c->base + OFFSET_CONTROL); mtk_i2c_init_hw()
266 writew(I2C_DELAY_LEN, i2c->base + OFFSET_DELAY_LEN); mtk_i2c_init_hw()
268 writel(I2C_DMA_HARD_RST, i2c->pdmabase + OFFSET_RST); mtk_i2c_init_hw()
270 writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_RST); mtk_i2c_init_hw()
274 * Calculate i2c port speed
281 * less than or equal to i2c->speed_hz. The calculation try to get
284 static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk, mtk_i2c_set_speed() argument
299 target_speed = i2c->speed_hz; mtk_i2c_set_speed()
342 dev_dbg(i2c->dev, "Unsupported speed (%uhz)\n", target_speed); mtk_i2c_set_speed()
351 i2c->timing_reg = I2C_FS_TIME_INIT_VALUE; mtk_i2c_set_speed()
352 i2c->high_speed_reg = I2C_TIME_DEFAULT_VALUE | mtk_i2c_set_speed()
355 i2c->timing_reg = (sample_cnt << 8) | (step_cnt << 0); mtk_i2c_set_speed()
357 i2c->high_speed_reg = I2C_TIME_CLR_VALUE; mtk_i2c_set_speed()
363 static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs, mtk_i2c_do_transfer() argument
374 i2c->irq_stat = 0; mtk_i2c_do_transfer()
376 if (i2c->dev_comp->auto_restart) mtk_i2c_do_transfer()
379 reinit_completion(&i2c->msg_complete); mtk_i2c_do_transfer()
381 control_reg = readw(i2c->base + OFFSET_CONTROL) & mtk_i2c_do_transfer()
383 if ((i2c->speed_hz > 400000) || (left_num >= 1)) mtk_i2c_do_transfer()
386 if (i2c->op == I2C_MASTER_WRRD) mtk_i2c_do_transfer()
389 writew(control_reg, i2c->base + OFFSET_CONTROL); mtk_i2c_do_transfer()
392 if (i2c->speed_hz <= 100000) mtk_i2c_do_transfer()
393 writew(I2C_ST_START_CON, i2c->base + OFFSET_EXT_CONF); mtk_i2c_do_transfer()
395 writew(I2C_FS_START_CON, i2c->base + OFFSET_EXT_CONF); mtk_i2c_do_transfer()
398 if (i2c->op == I2C_MASTER_RD) mtk_i2c_do_transfer()
401 writew(addr_reg, i2c->base + OFFSET_SLAVE_ADDR); mtk_i2c_do_transfer()
405 I2C_TRANSAC_COMP, i2c->base + OFFSET_INTR_STAT); mtk_i2c_do_transfer()
406 writew(I2C_FIFO_ADDR_CLR, i2c->base + OFFSET_FIFO_ADDR_CLR); mtk_i2c_do_transfer()
410 I2C_TRANSAC_COMP, i2c->base + OFFSET_INTR_MASK); mtk_i2c_do_transfer()
413 if (i2c->op == I2C_MASTER_WRRD) { mtk_i2c_do_transfer()
415 i2c->base + OFFSET_TRANSFER_LEN); mtk_i2c_do_transfer()
416 writew(I2C_WRRD_TRANAC_VALUE, i2c->base + OFFSET_TRANSAC_LEN); mtk_i2c_do_transfer()
418 writew(msgs->len, i2c->base + OFFSET_TRANSFER_LEN); mtk_i2c_do_transfer()
419 writew(num, i2c->base + OFFSET_TRANSAC_LEN); mtk_i2c_do_transfer()
423 if (i2c->op == I2C_MASTER_RD) { mtk_i2c_do_transfer()
424 writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); mtk_i2c_do_transfer()
425 writel(I2C_DMA_CON_RX, i2c->pdmabase + OFFSET_CON); mtk_i2c_do_transfer()
426 rpaddr = dma_map_single(i2c->dev, msgs->buf, mtk_i2c_do_transfer()
428 if (dma_mapping_error(i2c->dev, rpaddr)) mtk_i2c_do_transfer()
430 writel((u32)rpaddr, i2c->pdmabase + OFFSET_RX_MEM_ADDR); mtk_i2c_do_transfer()
431 writel(msgs->len, i2c->pdmabase + OFFSET_RX_LEN); mtk_i2c_do_transfer()
432 } else if (i2c->op == I2C_MASTER_WR) { mtk_i2c_do_transfer()
433 writel(I2C_DMA_INT_FLAG_NONE, i2c->pdmabase + OFFSET_INT_FLAG); mtk_i2c_do_transfer()
434 writel(I2C_DMA_CON_TX, i2c->pdmabase + OFFSET_CON); mtk_i2c_do_transfer()
435 wpaddr = dma_map_single(i2c->dev, msgs->buf, mtk_i2c_do_transfer()
437 if (dma_mapping_error(i2c->dev, wpaddr)) mtk_i2c_do_transfer()
439 writel((u32)wpaddr, i2c->pdmabase + OFFSET_TX_MEM_ADDR); mtk_i2c_do_transfer()
440 writel(msgs->len, i2c->pdmabase + OFFSET_TX_LEN); mtk_i2c_do_transfer()
442 writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_INT_FLAG); mtk_i2c_do_transfer()
443 writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_CON); mtk_i2c_do_transfer()
444 wpaddr = dma_map_single(i2c->dev, msgs->buf, mtk_i2c_do_transfer()
446 if (dma_mapping_error(i2c->dev, wpaddr)) mtk_i2c_do_transfer()
448 rpaddr = dma_map_single(i2c->dev, (msgs + 1)->buf, mtk_i2c_do_transfer()
451 if (dma_mapping_error(i2c->dev, rpaddr)) { mtk_i2c_do_transfer()
452 dma_unmap_single(i2c->dev, wpaddr, mtk_i2c_do_transfer()
456 writel((u32)wpaddr, i2c->pdmabase + OFFSET_TX_MEM_ADDR); mtk_i2c_do_transfer()
457 writel((u32)rpaddr, i2c->pdmabase + OFFSET_RX_MEM_ADDR); mtk_i2c_do_transfer()
458 writel(msgs->len, i2c->pdmabase + OFFSET_TX_LEN); mtk_i2c_do_transfer()
459 writel((msgs + 1)->len, i2c->pdmabase + OFFSET_RX_LEN); mtk_i2c_do_transfer()
462 writel(I2C_DMA_START_EN, i2c->pdmabase + OFFSET_EN); mtk_i2c_do_transfer()
464 if (!i2c->dev_comp->auto_restart) { mtk_i2c_do_transfer()
471 writew(start_reg, i2c->base + OFFSET_START); mtk_i2c_do_transfer()
473 ret = wait_for_completion_timeout(&i2c->msg_complete, mtk_i2c_do_transfer()
474 i2c->adap.timeout); mtk_i2c_do_transfer()
478 I2C_TRANSAC_COMP), i2c->base + OFFSET_INTR_MASK); mtk_i2c_do_transfer()
480 if (i2c->op == I2C_MASTER_WR) { mtk_i2c_do_transfer()
481 dma_unmap_single(i2c->dev, wpaddr, mtk_i2c_do_transfer()
483 } else if (i2c->op == I2C_MASTER_RD) { mtk_i2c_do_transfer()
484 dma_unmap_single(i2c->dev, rpaddr, mtk_i2c_do_transfer()
487 dma_unmap_single(i2c->dev, wpaddr, msgs->len, mtk_i2c_do_transfer()
489 dma_unmap_single(i2c->dev, rpaddr, (msgs + 1)->len, mtk_i2c_do_transfer()
494 dev_dbg(i2c->dev, "addr: %x, transfer timeout\n", msgs->addr); mtk_i2c_do_transfer()
495 mtk_i2c_init_hw(i2c); mtk_i2c_do_transfer()
499 completion_done(&i2c->msg_complete); mtk_i2c_do_transfer()
501 if (i2c->irq_stat & (I2C_HS_NACKERR | I2C_ACKERR)) { mtk_i2c_do_transfer()
502 dev_dbg(i2c->dev, "addr: %x, transfer ACK error\n", msgs->addr); mtk_i2c_do_transfer()
503 mtk_i2c_init_hw(i2c); mtk_i2c_do_transfer()
515 struct mtk_i2c *i2c = i2c_get_adapdata(adap); mtk_i2c_transfer() local
517 ret = mtk_i2c_clock_enable(i2c); mtk_i2c_transfer()
523 dev_dbg(i2c->dev, "data buffer is NULL.\n"); mtk_i2c_transfer()
529 i2c->op = I2C_MASTER_RD; mtk_i2c_transfer()
531 i2c->op = I2C_MASTER_WR; mtk_i2c_transfer()
533 if (!i2c->dev_comp->auto_restart) { mtk_i2c_transfer()
536 i2c->op = I2C_MASTER_WRRD; mtk_i2c_transfer()
542 ret = mtk_i2c_do_transfer(i2c, msgs, num, left_num); mtk_i2c_transfer()
552 mtk_i2c_clock_disable(i2c); mtk_i2c_transfer()
558 struct mtk_i2c *i2c = dev_id; mtk_i2c_irq() local
562 if (i2c->dev_comp->auto_restart) mtk_i2c_irq()
565 intr_stat = readw(i2c->base + OFFSET_INTR_STAT); mtk_i2c_irq()
566 writew(intr_stat, i2c->base + OFFSET_INTR_STAT); mtk_i2c_irq()
569 * when occurs ack error, i2c controller generate two interrupts mtk_i2c_irq()
571 * i2c->irq_stat need keep the two interrupt value. mtk_i2c_irq()
573 i2c->irq_stat |= intr_stat; mtk_i2c_irq()
574 if (i2c->irq_stat & (I2C_TRANSAC_COMP | restart_flag)) mtk_i2c_irq()
575 complete(&i2c->msg_complete); mtk_i2c_irq()
590 static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c, mtk_i2c_parse_dt() argument
595 ret = of_property_read_u32(np, "clock-frequency", &i2c->speed_hz); mtk_i2c_parse_dt()
597 i2c->speed_hz = I2C_DEFAULT_SPEED; mtk_i2c_parse_dt()
606 i2c->have_pmic = of_property_read_bool(np, "mediatek,have-pmic"); mtk_i2c_parse_dt()
607 i2c->use_push_pull = mtk_i2c_parse_dt()
617 struct mtk_i2c *i2c; mtk_i2c_probe() local
623 i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); mtk_i2c_probe()
624 if (!i2c) mtk_i2c_probe()
627 ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c, &clk_src_div); mtk_i2c_probe()
632 i2c->base = devm_ioremap_resource(&pdev->dev, res); mtk_i2c_probe()
633 if (IS_ERR(i2c->base)) mtk_i2c_probe()
634 return PTR_ERR(i2c->base); mtk_i2c_probe()
637 i2c->pdmabase = devm_ioremap_resource(&pdev->dev, res); mtk_i2c_probe()
638 if (IS_ERR(i2c->pdmabase)) mtk_i2c_probe()
639 return PTR_ERR(i2c->pdmabase); mtk_i2c_probe()
645 init_completion(&i2c->msg_complete); mtk_i2c_probe()
651 i2c->dev_comp = of_id->data; mtk_i2c_probe()
652 i2c->adap.dev.of_node = pdev->dev.of_node; mtk_i2c_probe()
653 i2c->dev = &pdev->dev; mtk_i2c_probe()
654 i2c->adap.dev.parent = &pdev->dev; mtk_i2c_probe()
655 i2c->adap.owner = THIS_MODULE; mtk_i2c_probe()
656 i2c->adap.algo = &mtk_i2c_algorithm; mtk_i2c_probe()
657 i2c->adap.quirks = i2c->dev_comp->quirks; mtk_i2c_probe()
658 i2c->adap.timeout = 2 * HZ; mtk_i2c_probe()
659 i2c->adap.retries = 1; mtk_i2c_probe()
661 if (i2c->have_pmic && !i2c->dev_comp->pmic_i2c) mtk_i2c_probe()
664 i2c->clk_main = devm_clk_get(&pdev->dev, "main"); mtk_i2c_probe()
665 if (IS_ERR(i2c->clk_main)) { mtk_i2c_probe()
667 return PTR_ERR(i2c->clk_main); mtk_i2c_probe()
670 i2c->clk_dma = devm_clk_get(&pdev->dev, "dma"); mtk_i2c_probe()
671 if (IS_ERR(i2c->clk_dma)) { mtk_i2c_probe()
673 return PTR_ERR(i2c->clk_dma); mtk_i2c_probe()
676 clk = i2c->clk_main; mtk_i2c_probe()
677 if (i2c->have_pmic) { mtk_i2c_probe()
678 i2c->clk_pmic = devm_clk_get(&pdev->dev, "pmic"); mtk_i2c_probe()
679 if (IS_ERR(i2c->clk_pmic)) { mtk_i2c_probe()
681 return PTR_ERR(i2c->clk_pmic); mtk_i2c_probe()
683 clk = i2c->clk_pmic; mtk_i2c_probe()
686 strlcpy(i2c->adap.name, I2C_DRV_NAME, sizeof(i2c->adap.name)); mtk_i2c_probe()
688 ret = mtk_i2c_set_speed(i2c, clk_get_rate(clk), clk_src_div); mtk_i2c_probe()
694 ret = mtk_i2c_clock_enable(i2c); mtk_i2c_probe()
699 mtk_i2c_init_hw(i2c); mtk_i2c_probe()
700 mtk_i2c_clock_disable(i2c); mtk_i2c_probe()
703 IRQF_TRIGGER_NONE, I2C_DRV_NAME, i2c); mtk_i2c_probe()
710 i2c_set_adapdata(&i2c->adap, i2c); mtk_i2c_probe()
711 ret = i2c_add_adapter(&i2c->adap); mtk_i2c_probe()
713 dev_err(&pdev->dev, "Failed to add i2c bus to i2c core\n"); mtk_i2c_probe()
717 platform_set_drvdata(pdev, i2c); mtk_i2c_probe()
724 struct mtk_i2c *i2c = platform_get_drvdata(pdev); mtk_i2c_remove() local
726 i2c_del_adapter(&i2c->adap); mtk_i2c_remove()
734 struct mtk_i2c *i2c = dev_get_drvdata(dev); mtk_i2c_resume() local
736 mtk_i2c_init_hw(i2c); mtk_i2c_resume()
H A Di2c-mxs.c21 #include <linux/i2c.h>
34 #define DRIVER_NAME "mxs-i2c"
74 #define MXS_I2C_DATA(i2c) ((i2c->dev_type == MXS_I2C_V1) ? 0x60 : 0xa0)
76 #define MXS_I2C_DEBUG0_CLR(i2c) ((i2c->dev_type == MXS_I2C_V1) ? 0x78 : 0xb8)
115 * @adapter: i2c subsystem adapter node
137 static int mxs_i2c_reset(struct mxs_i2c_dev *i2c) mxs_i2c_reset() argument
139 int ret = stmp_reset_block(i2c->regs); mxs_i2c_reset()
150 writel(i2c->timing0, i2c->regs + MXS_I2C_TIMING0); mxs_i2c_reset()
151 writel(i2c->timing1, i2c->regs + MXS_I2C_TIMING1); mxs_i2c_reset()
152 writel(i2c->timing2, i2c->regs + MXS_I2C_TIMING2); mxs_i2c_reset()
154 writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); mxs_i2c_reset()
159 static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c) mxs_i2c_dma_finish() argument
161 if (i2c->dma_read) { mxs_i2c_dma_finish()
162 dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); mxs_i2c_dma_finish()
163 dma_unmap_sg(i2c->dev, &i2c->sg_io[1], 1, DMA_FROM_DEVICE); mxs_i2c_dma_finish()
165 dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); mxs_i2c_dma_finish()
171 struct mxs_i2c_dev *i2c = param; mxs_i2c_dma_irq_callback() local
173 complete(&i2c->cmd_complete); mxs_i2c_dma_irq_callback()
174 mxs_i2c_dma_finish(i2c); mxs_i2c_dma_irq_callback()
181 struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap); mxs_i2c_dma_setup_xfer() local
184 i2c->dma_read = 1; mxs_i2c_dma_setup_xfer()
185 i2c->addr_data = (msg->addr << 1) | I2C_SMBUS_READ; mxs_i2c_dma_setup_xfer()
192 i2c->pio_data[0] = MXS_CMD_I2C_SELECT; mxs_i2c_dma_setup_xfer()
193 desc = dmaengine_prep_slave_sg(i2c->dmach, mxs_i2c_dma_setup_xfer()
194 (struct scatterlist *)&i2c->pio_data[0], mxs_i2c_dma_setup_xfer()
197 dev_err(i2c->dev, mxs_i2c_dma_setup_xfer()
203 sg_init_one(&i2c->sg_io[0], &i2c->addr_data, 1); mxs_i2c_dma_setup_xfer()
204 dma_map_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); mxs_i2c_dma_setup_xfer()
205 desc = dmaengine_prep_slave_sg(i2c->dmach, &i2c->sg_io[0], 1, mxs_i2c_dma_setup_xfer()
209 dev_err(i2c->dev, mxs_i2c_dma_setup_xfer()
219 i2c->pio_data[1] = flags | MXS_CMD_I2C_READ | mxs_i2c_dma_setup_xfer()
221 desc = dmaengine_prep_slave_sg(i2c->dmach, mxs_i2c_dma_setup_xfer()
222 (struct scatterlist *)&i2c->pio_data[1], mxs_i2c_dma_setup_xfer()
225 dev_err(i2c->dev, mxs_i2c_dma_setup_xfer()
231 sg_init_one(&i2c->sg_io[1], msg->buf, msg->len); mxs_i2c_dma_setup_xfer()
232 dma_map_sg(i2c->dev, &i2c->sg_io[1], 1, DMA_FROM_DEVICE); mxs_i2c_dma_setup_xfer()
233 desc = dmaengine_prep_slave_sg(i2c->dmach, &i2c->sg_io[1], 1, mxs_i2c_dma_setup_xfer()
237 dev_err(i2c->dev, mxs_i2c_dma_setup_xfer()
242 i2c->dma_read = 0; mxs_i2c_dma_setup_xfer()
243 i2c->addr_data = (msg->addr << 1) | I2C_SMBUS_WRITE; mxs_i2c_dma_setup_xfer()
250 i2c->pio_data[0] = flags | MXS_CMD_I2C_WRITE | mxs_i2c_dma_setup_xfer()
252 desc = dmaengine_prep_slave_sg(i2c->dmach, mxs_i2c_dma_setup_xfer()
253 (struct scatterlist *)&i2c->pio_data[0], mxs_i2c_dma_setup_xfer()
256 dev_err(i2c->dev, mxs_i2c_dma_setup_xfer()
262 sg_init_table(i2c->sg_io, 2); mxs_i2c_dma_setup_xfer()
263 sg_set_buf(&i2c->sg_io[0], &i2c->addr_data, 1); mxs_i2c_dma_setup_xfer()
264 sg_set_buf(&i2c->sg_io[1], msg->buf, msg->len); mxs_i2c_dma_setup_xfer()
265 dma_map_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); mxs_i2c_dma_setup_xfer()
266 desc = dmaengine_prep_slave_sg(i2c->dmach, i2c->sg_io, 2, mxs_i2c_dma_setup_xfer()
270 dev_err(i2c->dev, mxs_i2c_dma_setup_xfer()
281 desc->callback_param = i2c; mxs_i2c_dma_setup_xfer()
285 dma_async_issue_pending(i2c->dmach); mxs_i2c_dma_setup_xfer()
290 dma_unmap_sg(i2c->dev, &i2c->sg_io[1], 1, DMA_FROM_DEVICE); mxs_i2c_dma_setup_xfer()
292 dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); mxs_i2c_dma_setup_xfer()
294 dmaengine_terminate_all(i2c->dmach); mxs_i2c_dma_setup_xfer()
299 dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); mxs_i2c_dma_setup_xfer()
301 dmaengine_terminate_all(i2c->dmach); mxs_i2c_dma_setup_xfer()
305 static int mxs_i2c_pio_wait_xfer_end(struct mxs_i2c_dev *i2c) mxs_i2c_pio_wait_xfer_end() argument
309 while (readl(i2c->regs + MXS_I2C_CTRL0) & MXS_I2C_CTRL0_RUN) { mxs_i2c_pio_wait_xfer_end()
310 if (readl(i2c->regs + MXS_I2C_CTRL1) & mxs_i2c_pio_wait_xfer_end()
321 static int mxs_i2c_pio_check_error_state(struct mxs_i2c_dev *i2c) mxs_i2c_pio_check_error_state() argument
325 state = readl(i2c->regs + MXS_I2C_CTRL1_CLR) & MXS_I2C_IRQ_MASK; mxs_i2c_pio_check_error_state()
328 i2c->cmd_err = -ENXIO; mxs_i2c_pio_check_error_state()
333 i2c->cmd_err = -EIO; mxs_i2c_pio_check_error_state()
335 return i2c->cmd_err; mxs_i2c_pio_check_error_state()
338 static void mxs_i2c_pio_trigger_cmd(struct mxs_i2c_dev *i2c, u32 cmd) mxs_i2c_pio_trigger_cmd() argument
342 writel(cmd, i2c->regs + MXS_I2C_CTRL0); mxs_i2c_pio_trigger_cmd()
345 reg = readl(i2c->regs + MXS_I2C_CTRL0); mxs_i2c_pio_trigger_cmd()
347 writel(reg, i2c->regs + MXS_I2C_CTRL0); mxs_i2c_pio_trigger_cmd()
358 static void mxs_i2c_pio_trigger_write_cmd(struct mxs_i2c_dev *i2c, u32 cmd, mxs_i2c_pio_trigger_write_cmd() argument
361 writel(cmd, i2c->regs + MXS_I2C_CTRL0); mxs_i2c_pio_trigger_write_cmd()
363 if (i2c->dev_type == MXS_I2C_V1) mxs_i2c_pio_trigger_write_cmd()
364 writel(MXS_I2C_CTRL0_PIO_MODE, i2c->regs + MXS_I2C_CTRL0_SET); mxs_i2c_pio_trigger_write_cmd()
366 writel(data, i2c->regs + MXS_I2C_DATA(i2c)); mxs_i2c_pio_trigger_write_cmd()
367 writel(MXS_I2C_CTRL0_RUN, i2c->regs + MXS_I2C_CTRL0_SET); mxs_i2c_pio_trigger_write_cmd()
373 struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap); mxs_i2c_pio_setup_xfer() local
380 writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_CLR); mxs_i2c_pio_setup_xfer()
417 mxs_i2c_pio_trigger_write_cmd(i2c, MXS_CMD_I2C_SELECT, mxs_i2c_pio_setup_xfer()
420 ret = mxs_i2c_pio_wait_xfer_end(i2c); mxs_i2c_pio_setup_xfer()
422 dev_err(i2c->dev, mxs_i2c_pio_setup_xfer()
428 mxs_i2c_pio_trigger_cmd(i2c, mxs_i2c_pio_setup_xfer()
432 ret = mxs_i2c_pio_wait_xfer_end(i2c); mxs_i2c_pio_setup_xfer()
434 dev_err(i2c->dev, mxs_i2c_pio_setup_xfer()
439 data = readl(i2c->regs + MXS_I2C_DATA(i2c)); mxs_i2c_pio_setup_xfer()
510 dev_dbg(i2c->dev, mxs_i2c_pio_setup_xfer()
518 i2c->regs + MXS_I2C_DEBUG0_CLR(i2c)); mxs_i2c_pio_setup_xfer()
520 mxs_i2c_pio_trigger_write_cmd(i2c, mxs_i2c_pio_setup_xfer()
529 ret = mxs_i2c_pio_wait_xfer_end(i2c); mxs_i2c_pio_setup_xfer()
531 dev_err(i2c->dev, mxs_i2c_pio_setup_xfer()
537 ret = readl(i2c->regs + MXS_I2C_STAT) & mxs_i2c_pio_setup_xfer()
547 ret = mxs_i2c_pio_check_error_state(i2c); mxs_i2c_pio_setup_xfer()
551 writel(MXS_I2C_IRQ_MASK, i2c->regs + MXS_I2C_CTRL1_CLR); mxs_i2c_pio_setup_xfer()
552 writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); mxs_i2c_pio_setup_xfer()
555 if (i2c->dev_type == MXS_I2C_V1) mxs_i2c_pio_setup_xfer()
556 writel(MXS_I2C_CTRL0_PIO_MODE, i2c->regs + MXS_I2C_CTRL0_CLR); mxs_i2c_pio_setup_xfer()
567 struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap); mxs_i2c_xfer_msg() local
575 dev_dbg(i2c->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n", mxs_i2c_xfer_msg()
591 i2c->cmd_err = 0; mxs_i2c_xfer_msg()
596 mxs_i2c_reset(i2c); mxs_i2c_xfer_msg()
598 reinit_completion(&i2c->cmd_complete); mxs_i2c_xfer_msg()
603 time_left = wait_for_completion_timeout(&i2c->cmd_complete, mxs_i2c_xfer_msg()
608 ret = i2c->cmd_err; mxs_i2c_xfer_msg()
617 i2c->regs + MXS_I2C_CTRL1_SET); mxs_i2c_xfer_msg()
631 if (i2c->dev_type == MXS_I2C_V1) mxs_i2c_xfer_msg()
632 mxs_i2c_reset(i2c); mxs_i2c_xfer_msg()
634 dev_dbg(i2c->dev, "Done with err=%d\n", ret); mxs_i2c_xfer_msg()
639 dev_dbg(i2c->dev, "Timeout!\n"); mxs_i2c_xfer_msg()
640 mxs_i2c_dma_finish(i2c); mxs_i2c_xfer_msg()
641 ret = mxs_i2c_reset(i2c); mxs_i2c_xfer_msg()
670 struct mxs_i2c_dev *i2c = dev_id; mxs_i2c_isr() local
671 u32 stat = readl(i2c->regs + MXS_I2C_CTRL1) & MXS_I2C_IRQ_MASK; mxs_i2c_isr()
677 i2c->cmd_err = -ENXIO; mxs_i2c_isr()
682 i2c->cmd_err = -EIO; mxs_i2c_isr()
684 writel(stat, i2c->regs + MXS_I2C_CTRL1_CLR); mxs_i2c_isr()
694 static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, uint32_t speed) mxs_i2c_derive_timing() argument
701 struct device *dev = i2c->dev; mxs_i2c_derive_timing()
764 i2c->timing0 = (high_count << 16) | rcv_count; mxs_i2c_derive_timing()
765 i2c->timing1 = (low_count << 16) | xmit_count; mxs_i2c_derive_timing()
766 i2c->timing2 = (bus_free << 16 | leadin); mxs_i2c_derive_timing()
769 static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c) mxs_i2c_get_ofdata() argument
772 struct device *dev = i2c->dev; mxs_i2c_get_ofdata()
782 mxs_i2c_derive_timing(i2c, speed); mxs_i2c_get_ofdata()
789 .name = "imx23-i2c",
792 .name = "imx28-i2c",
799 { .compatible = "fsl,imx23-i2c", .data = &mxs_i2c_devtype[0], },
800 { .compatible = "fsl,imx28-i2c", .data = &mxs_i2c_devtype[1], },
810 struct mxs_i2c_dev *i2c; mxs_i2c_probe() local
815 i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); mxs_i2c_probe()
816 if (!i2c) mxs_i2c_probe()
821 i2c->dev_type = device_id->driver_data; mxs_i2c_probe()
825 i2c->regs = devm_ioremap_resource(&pdev->dev, res); mxs_i2c_probe()
826 if (IS_ERR(i2c->regs)) mxs_i2c_probe()
827 return PTR_ERR(i2c->regs); mxs_i2c_probe()
833 err = devm_request_irq(dev, irq, mxs_i2c_isr, 0, dev_name(dev), i2c); mxs_i2c_probe()
837 i2c->dev = dev; mxs_i2c_probe()
839 init_completion(&i2c->cmd_complete); mxs_i2c_probe()
842 err = mxs_i2c_get_ofdata(i2c); mxs_i2c_probe()
848 i2c->dmach = dma_request_slave_channel(dev, "rx-tx"); mxs_i2c_probe()
849 if (!i2c->dmach) { mxs_i2c_probe()
854 platform_set_drvdata(pdev, i2c); mxs_i2c_probe()
857 err = mxs_i2c_reset(i2c); mxs_i2c_probe()
861 adap = &i2c->adapter; mxs_i2c_probe()
868 i2c_set_adapdata(adap, i2c); mxs_i2c_probe()
873 i2c->regs + MXS_I2C_CTRL0_SET); mxs_i2c_probe()
882 struct mxs_i2c_dev *i2c = platform_get_drvdata(pdev); mxs_i2c_remove() local
884 i2c_del_adapter(&i2c->adapter); mxs_i2c_remove()
886 if (i2c->dmach) mxs_i2c_remove()
887 dma_release_channel(i2c->dmach); mxs_i2c_remove()
889 writel(MXS_I2C_CTRL0_SFTRST, i2c->regs + MXS_I2C_CTRL0_SET); mxs_i2c_remove()
H A Di2c-mpc.c5 * This is a combined i2c adapter and algorithm driver for the
27 #include <linux/i2c.h>
35 #define DRV_NAME "mpc-i2c"
81 void (*setup)(struct device_node *node, struct mpc_i2c *i2c,
86 static inline void writeccr(struct mpc_i2c *i2c, u32 x) writeccr() argument
88 writeb(x, i2c->base + MPC_I2C_CR); writeccr()
93 struct mpc_i2c *i2c = dev_id; mpc_i2c_isr() local
94 if (readb(i2c->base + MPC_I2C_SR) & CSR_MIF) { mpc_i2c_isr()
96 i2c->interrupt = readb(i2c->base + MPC_I2C_SR); mpc_i2c_isr()
97 writeb(0, i2c->base + MPC_I2C_SR); mpc_i2c_isr()
98 wake_up(&i2c->queue); mpc_i2c_isr()
109 static void mpc_i2c_fixup(struct mpc_i2c *i2c) mpc_i2c_fixup() argument
112 u32 delay_val = 1000000 / i2c->real_clk + 1; mpc_i2c_fixup()
118 writeccr(i2c, 0); mpc_i2c_fixup()
119 writeccr(i2c, CCR_MSTA | CCR_MTX | CCR_MEN); mpc_i2c_fixup()
120 readb(i2c->base + MPC_I2C_DR); mpc_i2c_fixup()
121 writeccr(i2c, CCR_MEN); mpc_i2c_fixup()
126 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) i2c_wait() argument
132 if (!i2c->irq) { i2c_wait()
133 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { i2c_wait()
136 dev_dbg(i2c->dev, "timeout\n"); i2c_wait()
137 writeccr(i2c, 0); i2c_wait()
142 cmd_err = readb(i2c->base + MPC_I2C_SR); i2c_wait()
143 writeb(0, i2c->base + MPC_I2C_SR); i2c_wait()
146 result = wait_event_timeout(i2c->queue, i2c_wait()
147 (i2c->interrupt & CSR_MIF), timeout); i2c_wait()
149 if (unlikely(!(i2c->interrupt & CSR_MIF))) { i2c_wait()
150 dev_dbg(i2c->dev, "wait timeout\n"); i2c_wait()
151 writeccr(i2c, 0); i2c_wait()
155 cmd_err = i2c->interrupt; i2c_wait()
156 i2c->interrupt = 0; i2c_wait()
163 dev_dbg(i2c->dev, "unfinished\n"); i2c_wait()
168 dev_dbg(i2c->dev, "MAL\n"); i2c_wait()
173 dev_dbg(i2c->dev, "No RXAK\n"); i2c_wait()
175 writeccr(i2c, CCR_MEN); i2c_wait()
238 struct mpc_i2c *i2c, mpc_i2c_setup_52xx()
244 dev_dbg(i2c->dev, "using fdr %d\n", mpc_i2c_setup_52xx()
245 readb(i2c->base + MPC_I2C_FDR)); mpc_i2c_setup_52xx()
249 ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler, &i2c->real_clk); mpc_i2c_setup_52xx()
252 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR); mpc_i2c_setup_52xx()
255 dev_info(i2c->dev, "clock %u Hz (fdr=%d)\n", i2c->real_clk, mpc_i2c_setup_52xx()
260 struct mpc_i2c *i2c, mpc_i2c_setup_52xx()
268 struct mpc_i2c *i2c, mpc_i2c_setup_512x()
278 "fsl,mpc5121-i2c-ctrl"); mpc_i2c_setup_512x()
282 /* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */ mpc_i2c_setup_512x()
292 mpc_i2c_setup_52xx(node, i2c, clock, prescaler); mpc_i2c_setup_512x()
296 struct mpc_i2c *i2c, mpc_i2c_setup_512x()
392 if (of_device_is_compatible(node, "fsl,mpc8544-i2c")) mpc_i2c_get_fdr_8xxx()
417 struct mpc_i2c *i2c, mpc_i2c_setup_8xxx()
423 dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n", mpc_i2c_setup_8xxx()
424 readb(i2c->base + MPC_I2C_DFSRR), mpc_i2c_setup_8xxx()
425 readb(i2c->base + MPC_I2C_FDR)); mpc_i2c_setup_8xxx()
429 ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler, &i2c->real_clk); mpc_i2c_setup_8xxx()
432 writeb(fdr & 0xff, i2c->base + MPC_I2C_FDR); mpc_i2c_setup_8xxx()
433 writeb((fdr >> 8) & 0xff, i2c->base + MPC_I2C_DFSRR); mpc_i2c_setup_8xxx()
436 dev_info(i2c->dev, "clock %d Hz (dfsrr=%d fdr=%d)\n", mpc_i2c_setup_8xxx()
437 i2c->real_clk, fdr >> 8, fdr & 0xff); mpc_i2c_setup_8xxx()
442 struct mpc_i2c *i2c, mpc_i2c_setup_8xxx()
448 static void mpc_i2c_start(struct mpc_i2c *i2c) mpc_i2c_start() argument
451 writeb(0, i2c->base + MPC_I2C_SR); mpc_i2c_start()
453 writeccr(i2c, CCR_MEN); mpc_i2c_start()
456 static void mpc_i2c_stop(struct mpc_i2c *i2c) mpc_i2c_stop() argument
458 writeccr(i2c, CCR_MEN); mpc_i2c_stop()
461 static int mpc_write(struct mpc_i2c *i2c, int target, mpc_write() argument
465 unsigned timeout = i2c->adap.timeout; mpc_write()
469 writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags); mpc_write()
471 writeb((target << 1), i2c->base + MPC_I2C_DR); mpc_write()
473 result = i2c_wait(i2c, timeout, 1); mpc_write()
479 writeb(data[i], i2c->base + MPC_I2C_DR); mpc_write()
481 result = i2c_wait(i2c, timeout, 1); mpc_write()
489 static int mpc_read(struct mpc_i2c *i2c, int target, mpc_read() argument
492 unsigned timeout = i2c->adap.timeout; mpc_read()
497 writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags); mpc_read()
499 writeb((target << 1) | 1, i2c->base + MPC_I2C_DR); mpc_read()
501 result = i2c_wait(i2c, timeout, 1); mpc_read()
507 writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_TXAK); mpc_read()
509 writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA); mpc_read()
511 readb(i2c->base + MPC_I2C_DR); mpc_read()
517 result = i2c_wait(i2c, timeout, 0); mpc_read()
528 writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA mpc_read()
532 writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA mpc_read()
536 byte = readb(i2c->base + MPC_I2C_DR); mpc_read()
551 writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA mpc_read()
566 struct mpc_i2c *i2c = i2c_get_adapdata(adap); mpc_xfer() local
568 mpc_i2c_start(i2c); mpc_xfer()
571 while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) { mpc_xfer()
573 dev_dbg(i2c->dev, "Interrupted\n"); mpc_xfer()
574 writeccr(i2c, 0); mpc_xfer()
578 u8 status = readb(i2c->base + MPC_I2C_SR); mpc_xfer()
580 dev_dbg(i2c->dev, "timeout\n"); mpc_xfer()
583 i2c->base + MPC_I2C_SR); mpc_xfer()
584 mpc_i2c_fixup(i2c); mpc_xfer()
593 dev_dbg(i2c->dev, mpc_xfer()
600 ret = mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i, mpc_xfer()
606 mpc_write(i2c, pmsg->addr, pmsg->buf, pmsg->len, i); mpc_xfer()
609 mpc_i2c_stop(i2c); /* Initiate STOP */ mpc_xfer()
612 while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) { mpc_xfer()
614 u8 status = readb(i2c->base + MPC_I2C_SR); mpc_xfer()
616 dev_dbg(i2c->dev, "timeout\n"); mpc_xfer()
619 i2c->base + MPC_I2C_SR); mpc_xfer()
620 mpc_i2c_fixup(i2c); mpc_xfer()
650 struct mpc_i2c *i2c; fsl_i2c_probe() local
663 i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); fsl_i2c_probe()
664 if (!i2c) fsl_i2c_probe()
667 i2c->dev = &op->dev; /* for debug and error output */ fsl_i2c_probe()
669 init_waitqueue_head(&i2c->queue); fsl_i2c_probe()
671 i2c->base = of_iomap(op->dev.of_node, 0); fsl_i2c_probe()
672 if (!i2c->base) { fsl_i2c_probe()
673 dev_err(i2c->dev, "failed to map controller\n"); fsl_i2c_probe()
678 i2c->irq = irq_of_parse_and_map(op->dev.of_node, 0); fsl_i2c_probe()
679 if (i2c->irq) { /* no i2c->irq implies polling */ fsl_i2c_probe()
680 result = request_irq(i2c->irq, mpc_i2c_isr, fsl_i2c_probe()
681 IRQF_SHARED, "i2c-mpc", i2c); fsl_i2c_probe()
683 dev_err(i2c->dev, "failed to attach interrupt\n"); fsl_i2c_probe()
699 i2c->clk_per = clk; fsl_i2c_probe()
714 data->setup(op->dev.of_node, i2c, clock, data->prescaler); fsl_i2c_probe()
718 mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock, 0); fsl_i2c_probe()
727 dev_info(i2c->dev, "timeout %u us\n", mpc_ops.timeout * 1000000 / HZ); fsl_i2c_probe()
729 platform_set_drvdata(op, i2c); fsl_i2c_probe()
731 i2c->adap = mpc_ops; fsl_i2c_probe()
733 scnprintf(i2c->adap.name, sizeof(i2c->adap.name), fsl_i2c_probe()
735 i2c_set_adapdata(&i2c->adap, i2c); fsl_i2c_probe()
736 i2c->adap.dev.parent = &op->dev; fsl_i2c_probe()
737 i2c->adap.dev.of_node = of_node_get(op->dev.of_node); fsl_i2c_probe()
739 result = i2c_add_adapter(&i2c->adap); fsl_i2c_probe()
741 dev_err(i2c->dev, "failed to add adapter\n"); fsl_i2c_probe()
748 if (i2c->clk_per) fsl_i2c_probe()
749 clk_disable_unprepare(i2c->clk_per); fsl_i2c_probe()
750 free_irq(i2c->irq, i2c); fsl_i2c_probe()
752 irq_dispose_mapping(i2c->irq); fsl_i2c_probe()
753 iounmap(i2c->base); fsl_i2c_probe()
755 kfree(i2c); fsl_i2c_probe()
761 struct mpc_i2c *i2c = platform_get_drvdata(op); fsl_i2c_remove() local
763 i2c_del_adapter(&i2c->adap); fsl_i2c_remove()
765 if (i2c->clk_per) fsl_i2c_remove()
766 clk_disable_unprepare(i2c->clk_per); fsl_i2c_remove()
768 if (i2c->irq) fsl_i2c_remove()
769 free_irq(i2c->irq, i2c); fsl_i2c_remove()
771 irq_dispose_mapping(i2c->irq); fsl_i2c_remove()
772 iounmap(i2c->base); fsl_i2c_remove()
773 kfree(i2c); fsl_i2c_remove()
780 struct mpc_i2c *i2c = dev_get_drvdata(dev); mpc_i2c_suspend() local
782 i2c->fdr = readb(i2c->base + MPC_I2C_FDR); mpc_i2c_suspend()
783 i2c->dfsrr = readb(i2c->base + MPC_I2C_DFSRR); mpc_i2c_suspend()
790 struct mpc_i2c *i2c = dev_get_drvdata(dev); mpc_i2c_resume() local
792 writeb(i2c->fdr, i2c->base + MPC_I2C_FDR); mpc_i2c_resume()
793 writeb(i2c->dfsrr, i2c->base + MPC_I2C_DFSRR); mpc_i2c_resume()
827 {.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
828 {.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
829 {.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
830 {.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, },
831 {.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
832 {.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
833 {.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
835 {.compatible = "fsl-i2c", },
237 mpc_i2c_setup_52xx(struct device_node *node, struct mpc_i2c *i2c, u32 clock, u32 prescaler) mpc_i2c_setup_52xx() argument
259 mpc_i2c_setup_52xx(struct device_node *node, struct mpc_i2c *i2c, u32 clock, u32 prescaler) mpc_i2c_setup_52xx() argument
267 mpc_i2c_setup_512x(struct device_node *node, struct mpc_i2c *i2c, u32 clock, u32 prescaler) mpc_i2c_setup_512x() argument
295 mpc_i2c_setup_512x(struct device_node *node, struct mpc_i2c *i2c, u32 clock, u32 prescaler) mpc_i2c_setup_512x() argument
416 mpc_i2c_setup_8xxx(struct device_node *node, struct mpc_i2c *i2c, u32 clock, u32 prescaler) mpc_i2c_setup_8xxx() argument
441 mpc_i2c_setup_8xxx(struct device_node *node, struct mpc_i2c *i2c, u32 clock, u32 prescaler) mpc_i2c_setup_8xxx() argument
H A Di2c-img-scb.c77 #include <linux/i2c.h>
292 /* Timing parameters for i2c modes (in ns) */
409 static void img_i2c_writel(struct img_i2c *i2c, u32 offset, u32 value) img_i2c_writel() argument
411 writel(value, i2c->base + offset); img_i2c_writel()
414 static u32 img_i2c_readl(struct img_i2c *i2c, u32 offset) img_i2c_readl() argument
416 return readl(i2c->base + offset); img_i2c_readl()
431 static void img_i2c_wr_rd_fence(struct img_i2c *i2c) img_i2c_wr_rd_fence() argument
433 if (i2c->need_wr_rd_fence) { img_i2c_wr_rd_fence()
434 img_i2c_writel(i2c, SCB_CORE_REV_REG, 0); img_i2c_wr_rd_fence()
435 img_i2c_writel(i2c, SCB_CORE_REV_REG, 0); img_i2c_wr_rd_fence()
439 static void img_i2c_switch_mode(struct img_i2c *i2c, enum img_i2c_mode mode) img_i2c_switch_mode() argument
441 i2c->mode = mode; img_i2c_switch_mode()
442 i2c->int_enable = img_i2c_int_enable_by_mode[mode]; img_i2c_switch_mode()
443 i2c->line_status = 0; img_i2c_switch_mode()
446 static void img_i2c_raw_op(struct img_i2c *i2c) img_i2c_raw_op() argument
448 i2c->raw_timeout = 0; img_i2c_raw_op()
449 img_i2c_writel(i2c, SCB_OVERRIDE_REG, img_i2c_raw_op()
455 ((i2c->at_cur_cmd & OVERRIDE_CMD_MASK) << OVERRIDE_CMD_SHIFT) | img_i2c_raw_op()
456 (i2c->at_cur_data << OVERRIDE_DATA_SHIFT)); img_i2c_raw_op()
467 static void img_i2c_atomic_op(struct img_i2c *i2c, int cmd, u8 data) img_i2c_atomic_op() argument
469 i2c->at_cur_cmd = cmd; img_i2c_atomic_op()
470 i2c->at_cur_data = data; img_i2c_atomic_op()
473 if (cmd == CMD_GEN_DATA && i2c->mode == MODE_ATOMIC) { img_i2c_atomic_op()
474 u32 line_status = img_i2c_readl(i2c, SCB_STATUS_REG); img_i2c_atomic_op()
478 img_i2c_switch_mode(i2c, MODE_RAW); img_i2c_atomic_op()
479 img_i2c_raw_op(i2c); img_i2c_atomic_op()
484 dev_dbg(i2c->adap.dev.parent, img_i2c_atomic_op()
487 i2c->at_t_done = (cmd == CMD_RET_DATA || cmd == CMD_RET_ACK); img_i2c_atomic_op()
488 i2c->at_slave_event = false; img_i2c_atomic_op()
489 i2c->line_status = 0; img_i2c_atomic_op()
491 img_i2c_writel(i2c, SCB_OVERRIDE_REG, img_i2c_atomic_op()
499 static void img_i2c_atomic_start(struct img_i2c *i2c) img_i2c_atomic_start() argument
501 img_i2c_switch_mode(i2c, MODE_ATOMIC); img_i2c_atomic_start()
502 img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable); img_i2c_atomic_start()
503 img_i2c_atomic_op(i2c, CMD_GEN_START, 0x00); img_i2c_atomic_start()
506 static void img_i2c_soft_reset(struct img_i2c *i2c) img_i2c_soft_reset() argument
508 i2c->t_halt = false; img_i2c_soft_reset()
509 img_i2c_writel(i2c, SCB_CONTROL_REG, 0); img_i2c_soft_reset()
510 img_i2c_writel(i2c, SCB_CONTROL_REG, img_i2c_soft_reset()
515 static void img_i2c_transaction_halt(struct img_i2c *i2c, bool t_halt) img_i2c_transaction_halt() argument
519 if (i2c->t_halt == t_halt) img_i2c_transaction_halt()
521 i2c->t_halt = t_halt; img_i2c_transaction_halt()
522 val = img_i2c_readl(i2c, SCB_CONTROL_REG); img_i2c_transaction_halt()
527 img_i2c_writel(i2c, SCB_CONTROL_REG, val); img_i2c_transaction_halt()
531 static void img_i2c_read_fifo(struct img_i2c *i2c) img_i2c_read_fifo() argument
533 while (i2c->msg.len) { img_i2c_read_fifo()
537 img_i2c_wr_rd_fence(i2c); img_i2c_read_fifo()
538 fifo_status = img_i2c_readl(i2c, SCB_FIFO_STATUS_REG); img_i2c_read_fifo()
542 data = img_i2c_readl(i2c, SCB_READ_DATA_REG); img_i2c_read_fifo()
543 *i2c->msg.buf = data; img_i2c_read_fifo()
545 img_i2c_writel(i2c, SCB_READ_FIFO_REG, 0xff); img_i2c_read_fifo()
546 i2c->msg.len--; img_i2c_read_fifo()
547 i2c->msg.buf++; img_i2c_read_fifo()
552 static void img_i2c_write_fifo(struct img_i2c *i2c) img_i2c_write_fifo() argument
554 while (i2c->msg.len) { img_i2c_write_fifo()
557 img_i2c_wr_rd_fence(i2c); img_i2c_write_fifo()
558 fifo_status = img_i2c_readl(i2c, SCB_FIFO_STATUS_REG); img_i2c_write_fifo()
562 img_i2c_writel(i2c, SCB_WRITE_DATA_REG, *i2c->msg.buf); img_i2c_write_fifo()
563 i2c->msg.len--; img_i2c_write_fifo()
564 i2c->msg.buf++; img_i2c_write_fifo()
568 if (!i2c->msg.len) img_i2c_write_fifo()
569 i2c->int_enable &= ~INT_FIFO_EMPTYING; img_i2c_write_fifo()
573 static void img_i2c_read(struct img_i2c *i2c) img_i2c_read() argument
575 img_i2c_switch_mode(i2c, MODE_AUTOMATIC); img_i2c_read()
576 if (!i2c->last_msg) img_i2c_read()
577 i2c->int_enable |= INT_SLAVE_EVENT; img_i2c_read()
579 img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable); img_i2c_read()
580 img_i2c_writel(i2c, SCB_READ_ADDR_REG, i2c->msg.addr); img_i2c_read()
581 img_i2c_writel(i2c, SCB_READ_COUNT_REG, i2c->msg.len); img_i2c_read()
583 img_i2c_transaction_halt(i2c, false); img_i2c_read()
584 mod_timer(&i2c->check_timer, jiffies + msecs_to_jiffies(1)); img_i2c_read()
588 static void img_i2c_write(struct img_i2c *i2c) img_i2c_write() argument
590 img_i2c_switch_mode(i2c, MODE_AUTOMATIC); img_i2c_write()
591 if (!i2c->last_msg) img_i2c_write()
592 i2c->int_enable |= INT_SLAVE_EVENT; img_i2c_write()
594 img_i2c_writel(i2c, SCB_WRITE_ADDR_REG, i2c->msg.addr); img_i2c_write()
595 img_i2c_writel(i2c, SCB_WRITE_COUNT_REG, i2c->msg.len); img_i2c_write()
597 img_i2c_transaction_halt(i2c, false); img_i2c_write()
598 mod_timer(&i2c->check_timer, jiffies + msecs_to_jiffies(1)); img_i2c_write()
599 img_i2c_write_fifo(i2c); img_i2c_write()
602 img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable); img_i2c_write()
610 static void img_i2c_complete_transaction(struct img_i2c *i2c, int status) img_i2c_complete_transaction() argument
612 img_i2c_switch_mode(i2c, MODE_INACTIVE); img_i2c_complete_transaction()
614 i2c->msg_status = status; img_i2c_complete_transaction()
615 img_i2c_transaction_halt(i2c, false); img_i2c_complete_transaction()
617 complete(&i2c->msg_complete); img_i2c_complete_transaction()
620 static unsigned int img_i2c_raw_atomic_delay_handler(struct img_i2c *i2c, img_i2c_raw_atomic_delay_handler() argument
624 img_i2c_atomic_op(i2c, i2c->at_cur_cmd, i2c->at_cur_data); img_i2c_raw_atomic_delay_handler()
625 img_i2c_switch_mode(i2c, MODE_ATOMIC); img_i2c_raw_atomic_delay_handler()
629 static unsigned int img_i2c_raw(struct img_i2c *i2c, u32 int_status, img_i2c_raw() argument
633 if (i2c->raw_timeout == 0) img_i2c_raw()
634 return img_i2c_raw_atomic_delay_handler(i2c, img_i2c_raw()
636 --i2c->raw_timeout; img_i2c_raw()
641 static unsigned int img_i2c_sequence(struct img_i2c *i2c, u32 int_status) img_i2c_sequence() argument
654 i2c->at_slave_event = true; img_i2c_sequence()
656 i2c->at_t_done = true; img_i2c_sequence()
658 if (!i2c->at_slave_event || !i2c->at_t_done) img_i2c_sequence()
662 if (i2c->at_cur_cmd >= 0 && img_i2c_sequence()
663 i2c->at_cur_cmd < ARRAY_SIZE(continue_bits)) { img_i2c_sequence()
664 unsigned int cont_bits = continue_bits[i2c->at_cur_cmd]; img_i2c_sequence()
668 if (!(i2c->line_status & cont_bits)) img_i2c_sequence()
673 /* follow the sequence of commands in i2c->seq */ img_i2c_sequence()
674 next_cmd = *i2c->seq; img_i2c_sequence()
677 img_i2c_writel(i2c, SCB_OVERRIDE_REG, 0); img_i2c_sequence()
682 ++i2c->seq; img_i2c_sequence()
683 next_data = *i2c->seq; img_i2c_sequence()
685 ++i2c->seq; img_i2c_sequence()
686 img_i2c_atomic_op(i2c, next_cmd, next_data); img_i2c_sequence()
691 static void img_i2c_reset_start(struct img_i2c *i2c) img_i2c_reset_start() argument
694 img_i2c_switch_mode(i2c, MODE_SEQUENCE); img_i2c_reset_start()
695 img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable); img_i2c_reset_start()
696 i2c->seq = img_i2c_reset_seq; img_i2c_reset_start()
697 i2c->at_slave_event = true; img_i2c_reset_start()
698 i2c->at_t_done = true; img_i2c_reset_start()
699 i2c->at_cur_cmd = -1; img_i2c_reset_start()
702 img_i2c_sequence(i2c, 0); img_i2c_reset_start()
705 static void img_i2c_stop_start(struct img_i2c *i2c) img_i2c_stop_start() argument
708 img_i2c_switch_mode(i2c, MODE_SEQUENCE); img_i2c_stop_start()
709 img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable); img_i2c_stop_start()
710 i2c->seq = img_i2c_stop_seq; img_i2c_stop_start()
711 i2c->at_slave_event = true; img_i2c_stop_start()
712 i2c->at_t_done = true; img_i2c_stop_start()
713 i2c->at_cur_cmd = -1; img_i2c_stop_start()
716 img_i2c_sequence(i2c, 0); img_i2c_stop_start()
719 static unsigned int img_i2c_atomic(struct img_i2c *i2c, img_i2c_atomic() argument
727 i2c->at_slave_event = true; img_i2c_atomic()
729 i2c->at_t_done = true; img_i2c_atomic()
731 if (!i2c->at_slave_event || !i2c->at_t_done) img_i2c_atomic()
733 if (i2c->line_status & LINESTAT_ABORT_DET) { img_i2c_atomic()
734 dev_dbg(i2c->adap.dev.parent, "abort condition detected\n"); img_i2c_atomic()
736 i2c->msg_status = -EIO; img_i2c_atomic()
740 /* i2c->at_cur_cmd may have completed */ img_i2c_atomic()
741 switch (i2c->at_cur_cmd) { img_i2c_atomic()
744 next_data = (i2c->msg.addr << 1); img_i2c_atomic()
745 if (i2c->msg.flags & I2C_M_RD) img_i2c_atomic()
749 if (i2c->line_status & LINESTAT_INPUT_HELD_V) img_i2c_atomic()
753 if (i2c->line_status & LINESTAT_ACK_DET) { img_i2c_atomic()
754 if (i2c->msg.len == 0) { img_i2c_atomic()
756 } else if (i2c->msg.flags & I2C_M_RD) { img_i2c_atomic()
760 next_data = *i2c->msg.buf; img_i2c_atomic()
761 --i2c->msg.len; img_i2c_atomic()
762 ++i2c->msg.buf; img_i2c_atomic()
764 } else if (i2c->line_status & LINESTAT_NACK_DET) { img_i2c_atomic()
765 i2c->msg_status = -EIO; img_i2c_atomic()
770 if (i2c->line_status & LINESTAT_INPUT_HELD_V) { img_i2c_atomic()
771 *i2c->msg.buf = (i2c->line_status & img_i2c_atomic()
774 --i2c->msg.len; img_i2c_atomic()
775 ++i2c->msg.buf; img_i2c_atomic()
776 if (i2c->msg.len) img_i2c_atomic()
783 if (i2c->line_status & LINESTAT_ACK_DET) { img_i2c_atomic()
786 i2c->msg_status = -EIO; img_i2c_atomic()
794 img_i2c_writel(i2c, SCB_OVERRIDE_REG, 0); img_i2c_atomic()
797 dev_err(i2c->adap.dev.parent, "bad atomic command %d\n", img_i2c_atomic()
798 i2c->at_cur_cmd); img_i2c_atomic()
799 i2c->msg_status = -EIO; img_i2c_atomic()
807 if (next_cmd == CMD_GEN_STOP && !i2c->msg_status && img_i2c_atomic()
808 !i2c->last_msg) img_i2c_atomic()
810 img_i2c_atomic_op(i2c, next_cmd, next_data); img_i2c_atomic()
821 struct img_i2c *i2c = (struct img_i2c *)arg; img_i2c_check_timer() local
825 spin_lock_irqsave(&i2c->lock, flags); img_i2c_check_timer()
826 line_status = img_i2c_readl(i2c, SCB_STATUS_REG); img_i2c_check_timer()
830 dev_dbg(i2c->adap.dev.parent, img_i2c_check_timer()
833 img_i2c_writel(i2c, SCB_INT_MASK_REG, img_i2c_check_timer()
834 i2c->int_enable | INT_SLAVE_EVENT); img_i2c_check_timer()
837 spin_unlock_irqrestore(&i2c->lock, flags); img_i2c_check_timer()
840 static unsigned int img_i2c_auto(struct img_i2c *i2c, img_i2c_auto() argument
848 dev_dbg(i2c->adap.dev.parent, "abort condition detected\n"); img_i2c_auto()
850 if ((i2c->msg.flags & I2C_M_RD) && img_i2c_auto()
852 img_i2c_read_fifo(i2c); img_i2c_auto()
854 i2c->msg_status = -EIO; img_i2c_auto()
855 img_i2c_stop_start(i2c); img_i2c_auto()
860 if (!i2c->last_msg && line_status & LINESTAT_START_BIT_DET) { img_i2c_auto()
861 img_i2c_transaction_halt(i2c, true); img_i2c_auto()
863 i2c->int_enable &= ~INT_SLAVE_EVENT; img_i2c_auto()
866 mod_timer(&i2c->check_timer, jiffies + msecs_to_jiffies(1)); img_i2c_auto()
868 if (i2c->msg.flags & I2C_M_RD) { img_i2c_auto()
870 img_i2c_read_fifo(i2c); img_i2c_auto()
871 if (i2c->msg.len == 0) img_i2c_auto()
884 i2c->msg.len == 0) img_i2c_auto()
886 img_i2c_write_fifo(i2c); img_i2c_auto()
895 struct img_i2c *i2c = (struct img_i2c *)dev_id; img_i2c_isr() local
901 int_status = img_i2c_readl(i2c, SCB_INT_STATUS_REG); img_i2c_isr()
903 img_i2c_writel(i2c, SCB_INT_CLEAR_REG, int_status); img_i2c_isr()
909 line_status = img_i2c_readl(i2c, SCB_STATUS_REG); img_i2c_isr()
911 img_i2c_writel(i2c, SCB_CLEAR_REG, img_i2c_isr()
914 img_i2c_wr_rd_fence(i2c); img_i2c_isr()
917 spin_lock(&i2c->lock); img_i2c_isr()
920 i2c->line_status &= ~LINESTAT_INPUT_DATA; img_i2c_isr()
921 i2c->line_status |= line_status; img_i2c_isr()
931 dev_crit(i2c->adap.dev.parent, img_i2c_isr()
933 (i2c->msg.flags & I2C_M_RD) ? "reading" : "writing", img_i2c_isr()
934 i2c->msg.addr); img_i2c_isr()
939 if (i2c->mode == MODE_ATOMIC) img_i2c_isr()
940 hret = img_i2c_atomic(i2c, int_status, line_status); img_i2c_isr()
941 else if (i2c->mode == MODE_AUTOMATIC) img_i2c_isr()
942 hret = img_i2c_auto(i2c, int_status, line_status); img_i2c_isr()
943 else if (i2c->mode == MODE_SEQUENCE) img_i2c_isr()
944 hret = img_i2c_sequence(i2c, int_status); img_i2c_isr()
945 else if (i2c->mode == MODE_WAITSTOP && (int_status & INT_SLAVE_EVENT) && img_i2c_isr()
948 else if (i2c->mode == MODE_RAW) img_i2c_isr()
949 hret = img_i2c_raw(i2c, int_status, line_status); img_i2c_isr()
954 img_i2c_writel(i2c, SCB_INT_CLEAR_REG, int_status & INT_LEVEL); img_i2c_isr()
962 if (!i2c->last_msg || i2c->line_status & LINESTAT_STOP_BIT_DET) img_i2c_isr()
965 img_i2c_switch_mode(i2c, MODE_WAITSTOP); img_i2c_isr()
972 img_i2c_complete_transaction(i2c, status); img_i2c_isr()
974 img_i2c_switch_mode(i2c, MODE_FATAL); img_i2c_isr()
978 img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable); img_i2c_isr()
980 spin_unlock(&i2c->lock); img_i2c_isr()
986 static int img_i2c_reset_bus(struct img_i2c *i2c) img_i2c_reset_bus() argument
991 spin_lock_irqsave(&i2c->lock, flags); img_i2c_reset_bus()
992 reinit_completion(&i2c->msg_complete); img_i2c_reset_bus()
993 img_i2c_reset_start(i2c); img_i2c_reset_bus()
994 spin_unlock_irqrestore(&i2c->lock, flags); img_i2c_reset_bus()
996 time_left = wait_for_completion_timeout(&i2c->msg_complete, img_i2c_reset_bus()
1006 struct img_i2c *i2c = i2c_get_adapdata(adap); img_i2c_xfer() local
1011 if (i2c->mode == MODE_SUSPEND) { img_i2c_xfer()
1016 if (i2c->mode == MODE_FATAL) img_i2c_xfer()
1036 ret = clk_prepare_enable(i2c->scb_clk); img_i2c_xfer()
1044 spin_lock_irqsave(&i2c->lock, flags); img_i2c_xfer()
1048 * original or we'll confuse drivers and i2c-dev. img_i2c_xfer()
1050 i2c->msg = *msg; img_i2c_xfer()
1051 i2c->msg_status = 0; img_i2c_xfer()
1060 i2c->last_msg = (i == num - 1); img_i2c_xfer()
1061 reinit_completion(&i2c->msg_complete); img_i2c_xfer()
1069 img_i2c_writel(i2c, SCB_INT_CLEAR_REG, ~0); img_i2c_xfer()
1070 img_i2c_writel(i2c, SCB_CLEAR_REG, ~0); img_i2c_xfer()
1073 img_i2c_atomic_start(i2c); img_i2c_xfer()
1075 img_i2c_read(i2c); img_i2c_xfer()
1077 img_i2c_write(i2c); img_i2c_xfer()
1078 spin_unlock_irqrestore(&i2c->lock, flags); img_i2c_xfer()
1080 time_left = wait_for_completion_timeout(&i2c->msg_complete, img_i2c_xfer()
1082 del_timer_sync(&i2c->check_timer); img_i2c_xfer()
1085 dev_err(adap->dev.parent, "i2c transfer timed out\n"); img_i2c_xfer()
1086 i2c->msg_status = -ETIMEDOUT; img_i2c_xfer()
1090 if (i2c->msg_status) img_i2c_xfer()
1094 clk_disable_unprepare(i2c->scb_clk); img_i2c_xfer()
1096 return i2c->msg_status ? i2c->msg_status : num; img_i2c_xfer()
1109 static int img_i2c_init(struct img_i2c *i2c) img_i2c_init() argument
1116 ret = clk_prepare_enable(i2c->scb_clk); img_i2c_init()
1120 rev = img_i2c_readl(i2c, SCB_CORE_REV_REG); img_i2c_init()
1122 dev_info(i2c->adap.dev.parent, img_i2c_init()
1126 clk_disable_unprepare(i2c->scb_clk); img_i2c_init()
1131 i2c->need_wr_rd_fence = true; img_i2c_init()
1136 if (i2c->bitrate <= timings[i].max_bitrate) { img_i2c_init()
1141 if (i2c->bitrate > timings[ARRAY_SIZE(timings) - 1].max_bitrate) { img_i2c_init()
1142 dev_warn(i2c->adap.dev.parent, img_i2c_init()
1144 i2c->bitrate, img_i2c_init()
1147 i2c->bitrate = timing.max_bitrate; img_i2c_init()
1150 bitrate_khz = i2c->bitrate / 1000; img_i2c_init()
1151 clk_khz = clk_get_rate(i2c->scb_clk) / 1000; img_i2c_init()
1187 img_i2c_writel(i2c, SCB_CLK_SET_REG, data); img_i2c_init()
1219 img_i2c_writel(i2c, SCB_TIME_TCKH_REG, tckh); img_i2c_init()
1220 img_i2c_writel(i2c, SCB_TIME_TCKL_REG, tckl); img_i2c_init()
1229 img_i2c_writel(i2c, SCB_TIME_TSDH_REG, data); img_i2c_init()
1238 img_i2c_writel(i2c, SCB_TIME_TPL_REG, data); img_i2c_init()
1244 img_i2c_writel(i2c, SCB_TIME_TPH_REG, data); img_i2c_init()
1247 img_i2c_writel(i2c, SCB_TIME_TSDL_REG, data + tsdh + 2); img_i2c_init()
1253 img_i2c_writel(i2c, SCB_TIME_TP2S_REG, data); img_i2c_init()
1255 img_i2c_writel(i2c, SCB_TIME_TBI_REG, TIMEOUT_TBI); img_i2c_init()
1256 img_i2c_writel(i2c, SCB_TIME_TSL_REG, TIMEOUT_TSL); img_i2c_init()
1257 img_i2c_writel(i2c, SCB_TIME_TDL_REG, TIMEOUT_TDL); img_i2c_init()
1260 img_i2c_soft_reset(i2c); img_i2c_init()
1263 img_i2c_writel(i2c, SCB_INT_MASK_REG, 0); img_i2c_init()
1266 img_i2c_writel(i2c, SCB_INT_CLEAR_REG, ~0); img_i2c_init()
1269 img_i2c_writel(i2c, SCB_CLEAR_REG, ~0); img_i2c_init()
1272 img_i2c_writel(i2c, SCB_INT_MASK_REG, i2c->int_enable); img_i2c_init()
1275 ret = img_i2c_reset_bus(i2c); img_i2c_init()
1277 clk_disable_unprepare(i2c->scb_clk); img_i2c_init()
1285 struct img_i2c *i2c; img_i2c_probe() local
1290 i2c = devm_kzalloc(&pdev->dev, sizeof(struct img_i2c), GFP_KERNEL); img_i2c_probe()
1291 if (!i2c) img_i2c_probe()
1295 i2c->base = devm_ioremap_resource(&pdev->dev, res); img_i2c_probe()
1296 if (IS_ERR(i2c->base)) img_i2c_probe()
1297 return PTR_ERR(i2c->base); img_i2c_probe()
1305 i2c->sys_clk = devm_clk_get(&pdev->dev, "sys"); img_i2c_probe()
1306 if (IS_ERR(i2c->sys_clk)) { img_i2c_probe()
1308 return PTR_ERR(i2c->sys_clk); img_i2c_probe()
1311 i2c->scb_clk = devm_clk_get(&pdev->dev, "scb"); img_i2c_probe()
1312 if (IS_ERR(i2c->scb_clk)) { img_i2c_probe()
1314 return PTR_ERR(i2c->scb_clk); img_i2c_probe()
1318 pdev->name, i2c); img_i2c_probe()
1325 init_timer(&i2c->check_timer); img_i2c_probe()
1326 i2c->check_timer.function = img_i2c_check_timer; img_i2c_probe()
1327 i2c->check_timer.data = (unsigned long)i2c; img_i2c_probe()
1329 i2c->bitrate = timings[0].max_bitrate; img_i2c_probe()
1331 i2c->bitrate = val; img_i2c_probe()
1333 i2c_set_adapdata(&i2c->adap, i2c); img_i2c_probe()
1334 i2c->adap.dev.parent = &pdev->dev; img_i2c_probe()
1335 i2c->adap.dev.of_node = node; img_i2c_probe()
1336 i2c->adap.owner = THIS_MODULE; img_i2c_probe()
1337 i2c->adap.algo = &img_i2c_algo; img_i2c_probe()
1338 i2c->adap.retries = 5; img_i2c_probe()
1339 i2c->adap.nr = pdev->id; img_i2c_probe()
1340 snprintf(i2c->adap.name, sizeof(i2c->adap.name), "IMG SCB I2C"); img_i2c_probe()
1342 img_i2c_switch_mode(i2c, MODE_INACTIVE); img_i2c_probe()
1343 spin_lock_init(&i2c->lock); img_i2c_probe()
1344 init_completion(&i2c->msg_complete); img_i2c_probe()
1346 platform_set_drvdata(pdev, i2c); img_i2c_probe()
1348 ret = clk_prepare_enable(i2c->sys_clk); img_i2c_probe()
1352 ret = img_i2c_init(i2c); img_i2c_probe()
1356 ret = i2c_add_numbered_adapter(&i2c->adap); img_i2c_probe()
1365 clk_disable_unprepare(i2c->sys_clk); img_i2c_probe()
1371 struct img_i2c *i2c = platform_get_drvdata(dev); img_i2c_remove() local
1373 i2c_del_adapter(&i2c->adap); img_i2c_remove()
1374 clk_disable_unprepare(i2c->sys_clk); img_i2c_remove()
1382 struct img_i2c *i2c = dev_get_drvdata(dev); img_i2c_suspend() local
1384 img_i2c_switch_mode(i2c, MODE_SUSPEND); img_i2c_suspend()
1386 clk_disable_unprepare(i2c->sys_clk); img_i2c_suspend()
1393 struct img_i2c *i2c = dev_get_drvdata(dev); img_i2c_resume() local
1396 ret = clk_prepare_enable(i2c->sys_clk); img_i2c_resume()
1400 img_i2c_init(i2c); img_i2c_resume()
1409 { .compatible = "img,scb-i2c" },
1416 .name = "img-i2c-scb",
H A Di2c-rk3x.c14 #include <linux/i2c.h>
87 * @grf_offset: offset inside the grf regmap for setting the i2c type
126 static inline void i2c_writel(struct rk3x_i2c *i2c, u32 value, i2c_writel() argument
129 writel(value, i2c->regs + offset); i2c_writel()
132 static inline u32 i2c_readl(struct rk3x_i2c *i2c, unsigned int offset) i2c_readl() argument
134 return readl(i2c->regs + offset); i2c_readl()
138 static inline void rk3x_i2c_clean_ipd(struct rk3x_i2c *i2c) rk3x_i2c_clean_ipd() argument
140 i2c_writel(i2c, REG_INT_ALL, REG_IPD); rk3x_i2c_clean_ipd()
146 static void rk3x_i2c_start(struct rk3x_i2c *i2c) rk3x_i2c_start() argument
150 rk3x_i2c_clean_ipd(i2c); rk3x_i2c_start()
151 i2c_writel(i2c, REG_INT_START, REG_IEN); rk3x_i2c_start()
154 val = REG_CON_EN | REG_CON_MOD(i2c->mode) | REG_CON_START; rk3x_i2c_start()
157 if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) rk3x_i2c_start()
160 i2c_writel(i2c, val, REG_CON); rk3x_i2c_start()
168 static void rk3x_i2c_stop(struct rk3x_i2c *i2c, int error) rk3x_i2c_stop() argument
172 i2c->processed = 0; rk3x_i2c_stop()
173 i2c->msg = NULL; rk3x_i2c_stop()
174 i2c->error = error; rk3x_i2c_stop()
176 if (i2c->is_last_msg) { rk3x_i2c_stop()
178 i2c_writel(i2c, REG_INT_STOP, REG_IEN); rk3x_i2c_stop()
180 i2c->state = STATE_STOP; rk3x_i2c_stop()
182 ctrl = i2c_readl(i2c, REG_CON); rk3x_i2c_stop()
184 i2c_writel(i2c, ctrl, REG_CON); rk3x_i2c_stop()
187 i2c->busy = false; rk3x_i2c_stop()
188 i2c->state = STATE_IDLE; rk3x_i2c_stop()
195 i2c_writel(i2c, 0, REG_CON); rk3x_i2c_stop()
198 wake_up(&i2c->wait); rk3x_i2c_stop()
203 * Setup a read according to i2c->msg
205 static void rk3x_i2c_prepare_read(struct rk3x_i2c *i2c) rk3x_i2c_prepare_read() argument
207 unsigned int len = i2c->msg->len - i2c->processed; rk3x_i2c_prepare_read()
210 con = i2c_readl(i2c, REG_CON); rk3x_i2c_prepare_read()
224 if (i2c->processed != 0) { rk3x_i2c_prepare_read()
229 i2c_writel(i2c, con, REG_CON); rk3x_i2c_prepare_read()
230 i2c_writel(i2c, len, REG_MRXCNT); rk3x_i2c_prepare_read()
234 * Fill the transmit buffer with data from i2c->msg
236 static void rk3x_i2c_fill_transmit_buf(struct rk3x_i2c *i2c) rk3x_i2c_fill_transmit_buf() argument
246 if ((i2c->processed == i2c->msg->len) && (cnt != 0)) rk3x_i2c_fill_transmit_buf()
249 if (i2c->processed == 0 && cnt == 0) rk3x_i2c_fill_transmit_buf()
250 byte = (i2c->addr & 0x7f) << 1; rk3x_i2c_fill_transmit_buf()
252 byte = i2c->msg->buf[i2c->processed++]; rk3x_i2c_fill_transmit_buf()
258 i2c_writel(i2c, val, TXBUFFER_BASE + 4 * i); rk3x_i2c_fill_transmit_buf()
260 if (i2c->processed == i2c->msg->len) rk3x_i2c_fill_transmit_buf()
264 i2c_writel(i2c, cnt, REG_MTXCNT); rk3x_i2c_fill_transmit_buf()
270 static void rk3x_i2c_handle_start(struct rk3x_i2c *i2c, unsigned int ipd) rk3x_i2c_handle_start() argument
273 rk3x_i2c_stop(i2c, -EIO); rk3x_i2c_handle_start()
274 dev_warn(i2c->dev, "unexpected irq in START: 0x%x\n", ipd); rk3x_i2c_handle_start()
275 rk3x_i2c_clean_ipd(i2c); rk3x_i2c_handle_start()
280 i2c_writel(i2c, REG_INT_START, REG_IPD); rk3x_i2c_handle_start()
283 i2c_writel(i2c, i2c_readl(i2c, REG_CON) & ~REG_CON_START, REG_CON); rk3x_i2c_handle_start()
286 if (i2c->mode == REG_CON_MOD_TX) { rk3x_i2c_handle_start()
287 i2c_writel(i2c, REG_INT_MBTF | REG_INT_NAKRCV, REG_IEN); rk3x_i2c_handle_start()
288 i2c->state = STATE_WRITE; rk3x_i2c_handle_start()
289 rk3x_i2c_fill_transmit_buf(i2c); rk3x_i2c_handle_start()
292 i2c_writel(i2c, REG_INT_MBRF | REG_INT_NAKRCV, REG_IEN); rk3x_i2c_handle_start()
293 i2c->state = STATE_READ; rk3x_i2c_handle_start()
294 rk3x_i2c_prepare_read(i2c); rk3x_i2c_handle_start()
298 static void rk3x_i2c_handle_write(struct rk3x_i2c *i2c, unsigned int ipd) rk3x_i2c_handle_write() argument
301 rk3x_i2c_stop(i2c, -EIO); rk3x_i2c_handle_write()
302 dev_err(i2c->dev, "unexpected irq in WRITE: 0x%x\n", ipd); rk3x_i2c_handle_write()
303 rk3x_i2c_clean_ipd(i2c); rk3x_i2c_handle_write()
308 i2c_writel(i2c, REG_INT_MBTF, REG_IPD); rk3x_i2c_handle_write()
311 if (i2c->processed == i2c->msg->len) rk3x_i2c_handle_write()
312 rk3x_i2c_stop(i2c, i2c->error); rk3x_i2c_handle_write()
314 rk3x_i2c_fill_transmit_buf(i2c); rk3x_i2c_handle_write()
317 static void rk3x_i2c_handle_read(struct rk3x_i2c *i2c, unsigned int ipd) rk3x_i2c_handle_read() argument
320 unsigned int len = i2c->msg->len - i2c->processed; rk3x_i2c_handle_read()
329 i2c_writel(i2c, REG_INT_MBRF, REG_IPD); rk3x_i2c_handle_read()
338 val = i2c_readl(i2c, RXBUFFER_BASE + (i / 4) * 4); rk3x_i2c_handle_read()
341 i2c->msg->buf[i2c->processed++] = byte; rk3x_i2c_handle_read()
345 if (i2c->processed == i2c->msg->len) rk3x_i2c_handle_read()
346 rk3x_i2c_stop(i2c, i2c->error); rk3x_i2c_handle_read()
348 rk3x_i2c_prepare_read(i2c); rk3x_i2c_handle_read()
351 static void rk3x_i2c_handle_stop(struct rk3x_i2c *i2c, unsigned int ipd) rk3x_i2c_handle_stop() argument
356 rk3x_i2c_stop(i2c, -EIO); rk3x_i2c_handle_stop()
357 dev_err(i2c->dev, "unexpected irq in STOP: 0x%x\n", ipd); rk3x_i2c_handle_stop()
358 rk3x_i2c_clean_ipd(i2c); rk3x_i2c_handle_stop()
363 i2c_writel(i2c, REG_INT_STOP, REG_IPD); rk3x_i2c_handle_stop()
366 con = i2c_readl(i2c, REG_CON); rk3x_i2c_handle_stop()
368 i2c_writel(i2c, con, REG_CON); rk3x_i2c_handle_stop()
370 i2c->busy = false; rk3x_i2c_handle_stop()
371 i2c->state = STATE_IDLE; rk3x_i2c_handle_stop()
374 wake_up(&i2c->wait); rk3x_i2c_handle_stop()
379 struct rk3x_i2c *i2c = dev_id; rk3x_i2c_irq() local
382 spin_lock(&i2c->lock); rk3x_i2c_irq()
384 ipd = i2c_readl(i2c, REG_IPD); rk3x_i2c_irq()
385 if (i2c->state == STATE_IDLE) { rk3x_i2c_irq()
386 dev_warn(i2c->dev, "irq in STATE_IDLE, ipd = 0x%x\n", ipd); rk3x_i2c_irq()
387 rk3x_i2c_clean_ipd(i2c); rk3x_i2c_irq()
391 dev_dbg(i2c->dev, "IRQ: state %d, ipd: %x\n", i2c->state, ipd); rk3x_i2c_irq()
402 i2c_writel(i2c, REG_INT_NAKRCV, REG_IPD); rk3x_i2c_irq()
406 if (!(i2c->msg->flags & I2C_M_IGNORE_NAK)) rk3x_i2c_irq()
407 rk3x_i2c_stop(i2c, -ENXIO); rk3x_i2c_irq()
414 switch (i2c->state) { rk3x_i2c_irq()
416 rk3x_i2c_handle_start(i2c, ipd); rk3x_i2c_irq()
419 rk3x_i2c_handle_write(i2c, ipd); rk3x_i2c_irq()
422 rk3x_i2c_handle_read(i2c, ipd); rk3x_i2c_irq()
425 rk3x_i2c_handle_stop(i2c, ipd); rk3x_i2c_irq()
432 spin_unlock(&i2c->lock); rk3x_i2c_irq()
491 * This is because the i2c host on Rockchip holds the data line rk3x_i2c_calc_divs()
617 static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate) rk3x_i2c_adapt_div() argument
623 ret = rk3x_i2c_calc_divs(clk_rate, i2c->scl_frequency, i2c->scl_rise_ns, rk3x_i2c_adapt_div()
624 i2c->scl_fall_ns, i2c->sda_fall_ns, rk3x_i2c_adapt_div()
626 WARN_ONCE(ret != 0, "Could not reach SCL freq %u", i2c->scl_frequency); rk3x_i2c_adapt_div()
628 clk_enable(i2c->clk); rk3x_i2c_adapt_div()
629 i2c_writel(i2c, (div_high << 16) | (div_low & 0xffff), REG_CLKDIV); rk3x_i2c_adapt_div()
630 clk_disable(i2c->clk); rk3x_i2c_adapt_div()
634 dev_dbg(i2c->dev, rk3x_i2c_adapt_div()
637 1000000000 / i2c->scl_frequency, rk3x_i2c_adapt_div()
652 * Code adapted from i2c-cadence.c.
662 struct rk3x_i2c *i2c = container_of(nb, struct rk3x_i2c, clk_rate_nb); rk3x_i2c_clk_notifier_cb() local
667 if (rk3x_i2c_calc_divs(ndata->new_rate, i2c->scl_frequency, rk3x_i2c_clk_notifier_cb()
668 i2c->scl_rise_ns, i2c->scl_fall_ns, rk3x_i2c_clk_notifier_cb()
669 i2c->sda_fall_ns, rk3x_i2c_clk_notifier_cb()
675 rk3x_i2c_adapt_div(i2c, ndata->new_rate); rk3x_i2c_clk_notifier_cb()
681 rk3x_i2c_adapt_div(i2c, ndata->new_rate); rk3x_i2c_clk_notifier_cb()
686 rk3x_i2c_adapt_div(i2c, ndata->old_rate); rk3x_i2c_clk_notifier_cb()
696 * Must be called with i2c->lock held.
703 static int rk3x_i2c_setup(struct rk3x_i2c *i2c, struct i2c_msg *msgs, int num) rk3x_i2c_setup() argument
720 dev_dbg(i2c->dev, "Combined write/read from addr 0x%x\n", rk3x_i2c_setup()
730 i2c->msg = &msgs[1]; rk3x_i2c_setup()
732 i2c->mode = REG_CON_MOD_REGISTER_TX; rk3x_i2c_setup()
734 i2c_writel(i2c, addr | REG_MRXADDR_VALID(0), REG_MRXADDR); rk3x_i2c_setup()
735 i2c_writel(i2c, reg_addr, REG_MRXRADDR); rk3x_i2c_setup()
751 i2c->mode = REG_CON_MOD_REGISTER_TX; rk3x_i2c_setup()
752 i2c_writel(i2c, addr | REG_MRXADDR_VALID(0), rk3x_i2c_setup()
754 i2c_writel(i2c, 0, REG_MRXRADDR); rk3x_i2c_setup()
756 i2c->mode = REG_CON_MOD_TX; rk3x_i2c_setup()
759 i2c->msg = &msgs[0]; rk3x_i2c_setup()
764 i2c->addr = msgs[0].addr; rk3x_i2c_setup()
765 i2c->busy = true; rk3x_i2c_setup()
766 i2c->state = STATE_START; rk3x_i2c_setup()
767 i2c->processed = 0; rk3x_i2c_setup()
768 i2c->error = 0; rk3x_i2c_setup()
770 rk3x_i2c_clean_ipd(i2c); rk3x_i2c_setup()
778 struct rk3x_i2c *i2c = (struct rk3x_i2c *)adap->algo_data; rk3x_i2c_xfer() local
783 spin_lock_irqsave(&i2c->lock, flags); rk3x_i2c_xfer()
785 clk_enable(i2c->clk); rk3x_i2c_xfer()
787 i2c->is_last_msg = false; rk3x_i2c_xfer()
794 ret = rk3x_i2c_setup(i2c, msgs + i, num - i); rk3x_i2c_xfer()
797 dev_err(i2c->dev, "rk3x_i2c_setup() failed\n"); rk3x_i2c_xfer()
802 i2c->is_last_msg = true; rk3x_i2c_xfer()
804 spin_unlock_irqrestore(&i2c->lock, flags); rk3x_i2c_xfer()
806 rk3x_i2c_start(i2c); rk3x_i2c_xfer()
808 timeout = wait_event_timeout(i2c->wait, !i2c->busy, rk3x_i2c_xfer()
811 spin_lock_irqsave(&i2c->lock, flags); rk3x_i2c_xfer()
814 dev_err(i2c->dev, "timeout, ipd: 0x%02x, state: %d\n", rk3x_i2c_xfer()
815 i2c_readl(i2c, REG_IPD), i2c->state); rk3x_i2c_xfer()
818 i2c_writel(i2c, 0, REG_IEN); rk3x_i2c_xfer()
819 i2c_writel(i2c, REG_CON_EN | REG_CON_STOP, REG_CON); rk3x_i2c_xfer()
821 i2c->state = STATE_IDLE; rk3x_i2c_xfer()
827 if (i2c->error) { rk3x_i2c_xfer()
828 ret = i2c->error; rk3x_i2c_xfer()
833 clk_disable(i2c->clk); rk3x_i2c_xfer()
834 spin_unlock_irqrestore(&i2c->lock, flags); rk3x_i2c_xfer()
856 { .compatible = "rockchip,rk3066-i2c", .data = (void *)&soc_data[0] },
857 { .compatible = "rockchip,rk3188-i2c", .data = (void *)&soc_data[1] },
858 { .compatible = "rockchip,rk3288-i2c", .data = (void *)&soc_data[2] },
867 struct rk3x_i2c *i2c; rk3x_i2c_probe() local
875 i2c = devm_kzalloc(&pdev->dev, sizeof(struct rk3x_i2c), GFP_KERNEL); rk3x_i2c_probe()
876 if (!i2c) rk3x_i2c_probe()
880 i2c->soc_data = (struct rk3x_i2c_soc_data *)match->data; rk3x_i2c_probe()
883 &i2c->scl_frequency)) { rk3x_i2c_probe()
886 i2c->scl_frequency = DEFAULT_SCL_RATE; rk3x_i2c_probe()
889 if (i2c->scl_frequency == 0 || i2c->scl_frequency > 400 * 1000) { rk3x_i2c_probe()
893 i2c->scl_frequency = DEFAULT_SCL_RATE; rk3x_i2c_probe()
900 if (of_property_read_u32(pdev->dev.of_node, "i2c-scl-rising-time-ns", rk3x_i2c_probe()
901 &i2c->scl_rise_ns)) { rk3x_i2c_probe()
902 if (i2c->scl_frequency <= 100000) rk3x_i2c_probe()
903 i2c->scl_rise_ns = 1000; rk3x_i2c_probe()
905 i2c->scl_rise_ns = 300; rk3x_i2c_probe()
907 if (of_property_read_u32(pdev->dev.of_node, "i2c-scl-falling-time-ns", rk3x_i2c_probe()
908 &i2c->scl_fall_ns)) rk3x_i2c_probe()
909 i2c->scl_fall_ns = 300; rk3x_i2c_probe()
910 if (of_property_read_u32(pdev->dev.of_node, "i2c-sda-falling-time-ns", rk3x_i2c_probe()
911 &i2c->sda_fall_ns)) rk3x_i2c_probe()
912 i2c->sda_fall_ns = i2c->scl_fall_ns; rk3x_i2c_probe()
914 strlcpy(i2c->adap.name, "rk3x-i2c", sizeof(i2c->adap.name)); rk3x_i2c_probe()
915 i2c->adap.owner = THIS_MODULE; rk3x_i2c_probe()
916 i2c->adap.algo = &rk3x_i2c_algorithm; rk3x_i2c_probe()
917 i2c->adap.retries = 3; rk3x_i2c_probe()
918 i2c->adap.dev.of_node = np; rk3x_i2c_probe()
919 i2c->adap.algo_data = i2c; rk3x_i2c_probe()
920 i2c->adap.dev.parent = &pdev->dev; rk3x_i2c_probe()
922 i2c->dev = &pdev->dev; rk3x_i2c_probe()
924 spin_lock_init(&i2c->lock); rk3x_i2c_probe()
925 init_waitqueue_head(&i2c->wait); rk3x_i2c_probe()
927 i2c->clk = devm_clk_get(&pdev->dev, NULL); rk3x_i2c_probe()
928 if (IS_ERR(i2c->clk)) { rk3x_i2c_probe()
930 return PTR_ERR(i2c->clk); rk3x_i2c_probe()
934 i2c->regs = devm_ioremap_resource(&pdev->dev, mem); rk3x_i2c_probe()
935 if (IS_ERR(i2c->regs)) rk3x_i2c_probe()
936 return PTR_ERR(i2c->regs); rk3x_i2c_probe()
939 bus_nr = of_alias_get_id(np, "i2c"); rk3x_i2c_probe()
945 if (i2c->soc_data->grf_offset >= 0) { rk3x_i2c_probe()
951 "rk3x-i2c needs 'rockchip,grf' property\n"); rk3x_i2c_probe()
956 dev_err(&pdev->dev, "rk3x-i2c needs i2cX alias"); rk3x_i2c_probe()
963 ret = regmap_write(grf, i2c->soc_data->grf_offset, value); rk3x_i2c_probe()
965 dev_err(i2c->dev, "Could not write to GRF: %d\n", ret); rk3x_i2c_probe()
978 0, dev_name(&pdev->dev), i2c); rk3x_i2c_probe()
984 platform_set_drvdata(pdev, i2c); rk3x_i2c_probe()
986 ret = clk_prepare(i2c->clk); rk3x_i2c_probe()
992 i2c->clk_rate_nb.notifier_call = rk3x_i2c_clk_notifier_cb; rk3x_i2c_probe()
993 ret = clk_notifier_register(i2c->clk, &i2c->clk_rate_nb); rk3x_i2c_probe()
999 clk_rate = clk_get_rate(i2c->clk); rk3x_i2c_probe()
1000 rk3x_i2c_adapt_div(i2c, clk_rate); rk3x_i2c_probe()
1002 ret = i2c_add_adapter(&i2c->adap); rk3x_i2c_probe()
1008 dev_info(&pdev->dev, "Initialized RK3xxx I2C bus at %p\n", i2c->regs); rk3x_i2c_probe()
1013 clk_notifier_unregister(i2c->clk, &i2c->clk_rate_nb); rk3x_i2c_probe()
1015 clk_unprepare(i2c->clk); rk3x_i2c_probe()
1021 struct rk3x_i2c *i2c = platform_get_drvdata(pdev); rk3x_i2c_remove() local
1023 i2c_del_adapter(&i2c->adap); rk3x_i2c_remove()
1025 clk_notifier_unregister(i2c->clk, &i2c->clk_rate_nb); rk3x_i2c_remove()
1026 clk_unprepare(i2c->clk); rk3x_i2c_remove()
1035 .name = "rk3x-i2c",
H A Di2c-viperboard.c2 * Nano River Technologies viperboard i2c master driver
24 #include <linux/i2c.h>
29 struct i2c_adapter i2c; member in struct:vprbrd_i2c
33 /* i2c bus frequency module parameter */
38 "i2c bus frequency in khz (default is 100) valid values: 10, 100, 200, 400, 1000, 3000, 6000");
40 static int vprbrd_i2c_status(struct i2c_adapter *i2c, vprbrd_i2c_status() argument
45 struct vprbrd *vb = (struct vprbrd *)i2c->algo_data; vprbrd_i2c_status()
58 dev_err(&i2c->dev, "failure in usb communication\n"); vprbrd_i2c_status()
62 dev_dbg(&i2c->dev, " status = %d\n", status->status); vprbrd_i2c_status()
64 dev_err(&i2c->dev, "failure: i2c protocol error\n"); vprbrd_i2c_status()
270 static int vprbrd_i2c_xfer(struct i2c_adapter *i2c, struct i2c_msg *msgs, vprbrd_i2c_xfer() argument
276 struct vprbrd *vb = (struct vprbrd *)i2c->algo_data; vprbrd_i2c_xfer()
281 dev_dbg(&i2c->dev, "master xfer %d messages:\n", num); vprbrd_i2c_xfer()
286 dev_dbg(&i2c->dev, vprbrd_i2c_xfer()
310 ret = vprbrd_i2c_status(i2c, smsg, error); vprbrd_i2c_xfer()
331 ret = vprbrd_i2c_status(i2c, smsg, error); vprbrd_i2c_xfer()
346 static u32 vprbrd_i2c_func(struct i2c_adapter *i2c) vprbrd_i2c_func() argument
373 /* setup i2c adapter description */ vprbrd_i2c_probe()
374 vb_i2c->i2c.owner = THIS_MODULE; vprbrd_i2c_probe()
375 vb_i2c->i2c.class = I2C_CLASS_HWMON; vprbrd_i2c_probe()
376 vb_i2c->i2c.algo = &vprbrd_algorithm; vprbrd_i2c_probe()
377 vb_i2c->i2c.quirks = &vprbrd_quirks; vprbrd_i2c_probe()
378 vb_i2c->i2c.algo_data = vb; vprbrd_i2c_probe()
382 snprintf(vb_i2c->i2c.name, sizeof(vb_i2c->i2c.name), vprbrd_i2c_probe()
405 vb_i2c->i2c.dev.parent = &pdev->dev; vprbrd_i2c_probe()
407 /* attach to i2c layer */ vprbrd_i2c_probe()
408 i2c_add_adapter(&vb_i2c->i2c); vprbrd_i2c_probe()
419 i2c_del_adapter(&vb_i2c->i2c); vprbrd_i2c_remove()
425 .driver.name = "viperboard-i2c",
473 MODULE_ALIAS("platform:viperboard-i2c");
H A Di2c-acorn.c2 * linux/drivers/acorn/char/i2c.c
10 * ARM IOC/IOMD i2c driver.
12 * On Acorn machines, the following i2c devices are on the bus:
16 #include <linux/i2c.h>
17 #include <linux/i2c-algo-bit.h>
28 * We must preserve all non-i2c output bits in IOC_CONTROL.
H A Di2c-cros-ec-tunnel.c13 #include <linux/i2c.h>
46 * @i2c_msgs: The i2c messages to read
47 * @num: The number of i2c messages.
72 * @i2c_msgs: The i2c messages to read.
73 * @num: The number of i2c messages.
115 * @i2c_msgs: The i2c messages to to fill up.
116 * @num: The number of i2c messages expected.
139 * @i2c_msgs: The i2c messages to to fill up.
140 * @num: The number of i2c messages; will be modified to include the actual
209 dev_err(dev, "Error constructing EC i2c message %d\n", result); ec_i2c_xfer()
220 dev_err(dev, "Error transferring EC i2c message %d\n", result); ec_i2c_xfer()
226 dev_err(dev, "Error parsing EC i2c message %d\n", result); ec_i2c_xfer()
276 strlcpy(bus->adap.name, "cros-ec-i2c-tunnel", sizeof(bus->adap.name)); ec_i2c_probe()
285 dev_err(dev, "cannot register i2c adapter\n"); ec_i2c_probe()
304 { .compatible = "google,cros-ec-i2c-tunnel" },
314 .name = "cros-ec-i2c-tunnel",
323 MODULE_ALIAS("platform:cros-ec-i2c-tunnel");
H A Di2c-tiny-usb.c2 * driver for the i2c-tiny-usb adapter - 1.0
22 /* include interface to i2c layer */
23 #include <linux/i2c.h>
35 /* i2c bit delay, default is 10us -> 100kHz max
36 (in practice, due to additional delays in the i2c bitbanging
37 code this results in a i2c clock of about 50kHz) */
49 /* ----- begin of i2c layer ---------------------------------------------- */
153 /* ----- end of i2c layer ------------------------------------------------ */
158 * Initially the usb i2c interface uses a vid/pid pair donated by
174 struct i2c_adapter adapter; /* i2c related things */
233 /* setup i2c adapter description */ i2c_tiny_usb_probe()
239 "i2c-tiny-usb at bus %03d device %03d", i2c_tiny_usb_probe()
251 /* and finally attach to i2c layer */ i2c_tiny_usb_probe()
254 /* inform user about successful attachment to i2c layer */ i2c_tiny_usb_probe()
255 dev_info(&dev->adapter.dev, "connected i2c-tiny-usb device\n"); i2c_tiny_usb_probe()
278 .name = "i2c-tiny-usb",
289 MODULE_DESCRIPTION("i2c-tiny-usb driver v1.0");
/linux-4.4.14/drivers/i2c/
H A DMakefile2 # Makefile for the i2c core.
5 obj-$(CONFIG_I2C_BOARDINFO) += i2c-boardinfo.o
6 obj-$(CONFIG_I2C) += i2c-core.o
7 obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o
8 obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
9 obj-$(CONFIG_I2C_MUX) += i2c-mux.o
11 obj-$(CONFIG_I2C_STUB) += i2c-stub.o
12 obj-$(CONFIG_I2C_SLAVE_EEPROM) += i2c-slave-eeprom.o
/linux-4.4.14/arch/mips/sibyte/swarm/
H A DMakefile4 obj-$(CONFIG_I2C_BOARDINFO) += swarm-i2c.o
H A Dswarm-i2c.c12 #include <linux/i2c.h>
31 "swarm-i2c: cannot register board I2C devices\n"); swarm_i2c_init()
/linux-4.4.14/drivers/media/pci/netup_unidvb/
H A Dnetup_unidvb_i2c.c74 irqreturn_t netup_i2c_interrupt(struct netup_i2c *i2c) netup_i2c_interrupt() argument
80 spin_lock_irqsave(&i2c->lock, flags); netup_i2c_interrupt()
81 reg = readw(&i2c->regs->twi_ctrl0_stat); netup_i2c_interrupt()
82 writew(reg & ~TWI_IRQEN, &i2c->regs->twi_ctrl0_stat); netup_i2c_interrupt()
83 dev_dbg(i2c->adap.dev.parent, netup_i2c_interrupt()
86 dev_dbg(i2c->adap.dev.parent, netup_i2c_interrupt()
88 i2c->state = STATE_DONE; netup_i2c_interrupt()
92 dev_dbg(i2c->adap.dev.parent, netup_i2c_interrupt()
94 i2c->state = STATE_ERROR; netup_i2c_interrupt()
98 dev_dbg(i2c->adap.dev.parent, netup_i2c_interrupt()
100 i2c->state = STATE_ERROR; netup_i2c_interrupt()
104 tmp = readw(&i2c->regs->rx_fifo.stat_ctrl); netup_i2c_interrupt()
105 writew(tmp & ~FIFO_IRQEN, &i2c->regs->rx_fifo.stat_ctrl); netup_i2c_interrupt()
106 i2c->state = STATE_WANT_READ; netup_i2c_interrupt()
107 dev_dbg(i2c->adap.dev.parent, netup_i2c_interrupt()
112 tmp = readw(&i2c->regs->tx_fifo.stat_ctrl); netup_i2c_interrupt()
113 writew(tmp & ~FIFO_IRQEN, &i2c->regs->tx_fifo.stat_ctrl); netup_i2c_interrupt()
114 i2c->state = STATE_WANT_WRITE; netup_i2c_interrupt()
115 dev_dbg(i2c->adap.dev.parent, netup_i2c_interrupt()
119 dev_warn(&i2c->adap.dev, "%s(): not mine interrupt\n", __func__); netup_i2c_interrupt()
122 spin_unlock_irqrestore(&i2c->lock, flags); netup_i2c_interrupt()
124 wake_up(&i2c->wq); netup_i2c_interrupt()
128 static void netup_i2c_reset(struct netup_i2c *i2c) netup_i2c_reset() argument
130 dev_dbg(i2c->adap.dev.parent, "%s()\n", __func__); netup_i2c_reset()
131 i2c->state = STATE_DONE; netup_i2c_reset()
132 writew(TWI_SOFT_RESET, &i2c->regs->twi_addr_ctrl1); netup_i2c_reset()
133 writew(TWI_CLKDIV, &i2c->regs->clkdiv); netup_i2c_reset()
134 writew(FIFO_RESET, &i2c->regs->tx_fifo.stat_ctrl); netup_i2c_reset()
135 writew(FIFO_RESET, &i2c->regs->rx_fifo.stat_ctrl); netup_i2c_reset()
136 writew(0x800, &i2c->regs->tx_fifo.stat_ctrl); netup_i2c_reset()
137 writew(0x800, &i2c->regs->rx_fifo.stat_ctrl); netup_i2c_reset()
140 static void netup_i2c_fifo_tx(struct netup_i2c *i2c) netup_i2c_fifo_tx() argument
144 (readw(&i2c->regs->tx_fifo.stat_ctrl) & 0x3f); netup_i2c_fifo_tx()
145 u32 msg_length = i2c->msg->len - i2c->xmit_size; netup_i2c_fifo_tx()
149 data = i2c->msg->buf[i2c->xmit_size++]; netup_i2c_fifo_tx()
150 writeb(data, &i2c->regs->tx_fifo.data8); netup_i2c_fifo_tx()
151 dev_dbg(i2c->adap.dev.parent, netup_i2c_fifo_tx()
154 if (i2c->xmit_size < i2c->msg->len) { netup_i2c_fifo_tx()
155 dev_dbg(i2c->adap.dev.parent, netup_i2c_fifo_tx()
157 writew(readw(&i2c->regs->tx_fifo.stat_ctrl) | FIFO_IRQEN, netup_i2c_fifo_tx()
158 &i2c->regs->tx_fifo.stat_ctrl); netup_i2c_fifo_tx()
162 static void netup_i2c_fifo_rx(struct netup_i2c *i2c) netup_i2c_fifo_rx() argument
165 u32 fifo_size = readw(&i2c->regs->rx_fifo.stat_ctrl) & 0x3f; netup_i2c_fifo_rx()
167 dev_dbg(i2c->adap.dev.parent, netup_i2c_fifo_rx()
170 data = readb(&i2c->regs->rx_fifo.data8); netup_i2c_fifo_rx()
171 if ((i2c->msg->flags & I2C_M_RD) != 0 && netup_i2c_fifo_rx()
172 i2c->xmit_size < i2c->msg->len) { netup_i2c_fifo_rx()
173 i2c->msg->buf[i2c->xmit_size++] = data; netup_i2c_fifo_rx()
174 dev_dbg(i2c->adap.dev.parent, netup_i2c_fifo_rx()
178 if (i2c->xmit_size < i2c->msg->len) { netup_i2c_fifo_rx()
179 dev_dbg(i2c->adap.dev.parent, netup_i2c_fifo_rx()
181 writew(readw(&i2c->regs->rx_fifo.stat_ctrl) | FIFO_IRQEN, netup_i2c_fifo_rx()
182 &i2c->regs->rx_fifo.stat_ctrl); netup_i2c_fifo_rx()
186 static void netup_i2c_start_xfer(struct netup_i2c *i2c) netup_i2c_start_xfer() argument
188 u16 rdflag = ((i2c->msg->flags & I2C_M_RD) ? 1 : 0); netup_i2c_start_xfer()
189 u16 reg = readw(&i2c->regs->twi_ctrl0_stat); netup_i2c_start_xfer()
191 writew(TWI_IRQEN | reg, &i2c->regs->twi_ctrl0_stat); netup_i2c_start_xfer()
192 writew(i2c->msg->len, &i2c->regs->length); netup_i2c_start_xfer()
193 writew(TWI_TRANSFER | (i2c->msg->addr << 1) | rdflag, netup_i2c_start_xfer()
194 &i2c->regs->twi_addr_ctrl1); netup_i2c_start_xfer()
195 dev_dbg(i2c->adap.dev.parent, netup_i2c_start_xfer()
197 __func__, readw(&i2c->regs->length), netup_i2c_start_xfer()
198 readw(&i2c->regs->twi_addr_ctrl1), netup_i2c_start_xfer()
199 readw(&i2c->regs->twi_ctrl0_stat)); netup_i2c_start_xfer()
200 i2c->state = STATE_WAIT; netup_i2c_start_xfer()
201 i2c->xmit_size = 0; netup_i2c_start_xfer()
203 netup_i2c_fifo_tx(i2c); netup_i2c_start_xfer()
205 writew(FIFO_IRQEN | readw(&i2c->regs->rx_fifo.stat_ctrl), netup_i2c_start_xfer()
206 &i2c->regs->rx_fifo.stat_ctrl); netup_i2c_start_xfer()
214 struct netup_i2c *i2c = i2c_get_adapdata(adap); netup_i2c_xfer() local
218 dev_dbg(i2c->adap.dev.parent, netup_i2c_xfer()
222 spin_lock_irqsave(&i2c->lock, flags); netup_i2c_xfer()
223 if (i2c->state != STATE_DONE) { netup_i2c_xfer()
224 dev_dbg(i2c->adap.dev.parent, netup_i2c_xfer()
225 "%s(): i2c->state == %d, resetting I2C\n", netup_i2c_xfer()
226 __func__, i2c->state); netup_i2c_xfer()
227 netup_i2c_reset(i2c); netup_i2c_xfer()
229 dev_dbg(i2c->adap.dev.parent, "%s() num %d\n", __func__, num); netup_i2c_xfer()
231 i2c->msg = &msgs[i]; netup_i2c_xfer()
232 netup_i2c_start_xfer(i2c); netup_i2c_xfer()
235 spin_unlock_irqrestore(&i2c->lock, flags); netup_i2c_xfer()
236 if (wait_event_timeout(i2c->wq, netup_i2c_xfer()
237 i2c->state != STATE_WAIT, netup_i2c_xfer()
239 spin_lock_irqsave(&i2c->lock, flags); netup_i2c_xfer()
240 switch (i2c->state) { netup_i2c_xfer()
242 netup_i2c_fifo_rx(i2c); netup_i2c_xfer()
245 netup_i2c_fifo_tx(i2c); netup_i2c_xfer()
248 if ((i2c->msg->flags & I2C_M_RD) != 0 && netup_i2c_xfer()
249 i2c->xmit_size != i2c->msg->len) netup_i2c_xfer()
250 netup_i2c_fifo_rx(i2c); netup_i2c_xfer()
251 dev_dbg(i2c->adap.dev.parent, netup_i2c_xfer()
258 dev_dbg(i2c->adap.dev.parent, netup_i2c_xfer()
263 dev_dbg(i2c->adap.dev.parent, netup_i2c_xfer()
265 __func__, i2c->state); netup_i2c_xfer()
270 i2c->state = STATE_WAIT; netup_i2c_xfer()
272 &i2c->regs->twi_ctrl0_stat); netup_i2c_xfer()
274 &i2c->regs->twi_ctrl0_stat); netup_i2c_xfer()
276 spin_unlock_irqrestore(&i2c->lock, flags); netup_i2c_xfer()
278 spin_lock_irqsave(&i2c->lock, flags); netup_i2c_xfer()
279 dev_dbg(i2c->adap.dev.parent, netup_i2c_xfer()
284 spin_lock_irqsave(&i2c->lock, flags); netup_i2c_xfer()
288 spin_unlock_irqrestore(&i2c->lock, flags); netup_i2c_xfer()
289 dev_dbg(i2c->adap.dev.parent, "%s(): result %d\n", __func__, res); netup_i2c_xfer()
313 struct netup_i2c *i2c; netup_i2c_init() local
320 i2c = &ndev->i2c[bus_num]; netup_i2c_init()
321 spin_lock_init(&i2c->lock); netup_i2c_init()
322 init_waitqueue_head(&i2c->wq); netup_i2c_init()
323 i2c->regs = (struct netup_i2c_regs __iomem *)(ndev->bmmio0 + netup_i2c_init()
325 netup_i2c_reset(i2c); netup_i2c_init()
326 i2c->adap = netup_i2c_adapter; netup_i2c_init()
327 i2c->adap.dev.parent = &ndev->pci_dev->dev; netup_i2c_init()
328 i2c_set_adapdata(&i2c->adap, i2c); netup_i2c_init()
329 ret = i2c_add_adapter(&i2c->adap); netup_i2c_init()
346 struct netup_i2c *i2c; netup_i2c_remove() local
353 i2c = &ndev->i2c[bus_num]; netup_i2c_remove()
354 netup_i2c_reset(i2c); netup_i2c_remove()
356 i2c_del_adapter(&i2c->adap); netup_i2c_remove()
/linux-4.4.14/sound/i2c/
H A DMakefile6 snd-i2c-objs := i2c.o
13 obj-$(CONFIG_SND_INTERWAVE_STB) += snd-tea6330t.o snd-i2c.o
14 obj-$(CONFIG_SND_ICE1712) += snd-cs8427.o snd-i2c.o
15 obj-$(CONFIG_SND_ICE1724) += snd-i2c.o
/linux-4.4.14/drivers/media/radio/si470x/
H A DMakefile6 radio-i2c-si470x-objs := radio-si470x-i2c.o radio-si470x-common.o
9 obj-$(CONFIG_I2C_SI470X) += radio-i2c-si470x.o
/linux-4.4.14/drivers/media/pci/cx25821/
H A DMakefile1 cx25821-y := cx25821-core.o cx25821-cards.o cx25821-i2c.o \
8 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/media/usb/hdpvr/
H A DMakefile1 hdpvr-objs := hdpvr-control.o hdpvr-core.o hdpvr-video.o hdpvr-i2c.o
5 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/media/usb/stk1160/
H A DMakefile6 stk1160-i2c.o \
11 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/media/usb/usbvision/
H A DMakefile1 usbvision-objs := usbvision-core.o usbvision-video.o usbvision-i2c.o usbvision-cards.o
5 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/gpu/drm/mgag200/
H A Dmgag200_i2c.c29 #include <linux/i2c.h>
30 #include <linux/i2c-algo-bit.h>
62 struct mga_i2c_chan *i2c = data; mga_gpio_setsda() local
63 struct mga_device *mdev = i2c->dev->dev_private; mga_gpio_setsda()
64 mga_i2c_set(mdev, i2c->data, state); mga_gpio_setsda()
69 struct mga_i2c_chan *i2c = data; mga_gpio_setscl() local
70 struct mga_device *mdev = i2c->dev->dev_private; mga_gpio_setscl()
71 mga_i2c_set(mdev, i2c->clock, state); mga_gpio_setscl()
76 struct mga_i2c_chan *i2c = data; mga_gpio_getsda() local
77 struct mga_device *mdev = i2c->dev->dev_private; mga_gpio_getsda()
78 return (mga_i2c_read_gpio(mdev) & i2c->data) ? 1 : 0; mga_gpio_getsda()
83 struct mga_i2c_chan *i2c = data; mga_gpio_getscl() local
84 struct mga_device *mdev = i2c->dev->dev_private; mga_gpio_getscl()
85 return (mga_i2c_read_gpio(mdev) & i2c->clock) ? 1 : 0; mga_gpio_getscl()
91 struct mga_i2c_chan *i2c; mgag200_i2c_create() local
119 i2c = kzalloc(sizeof(struct mga_i2c_chan), GFP_KERNEL); mgag200_i2c_create()
120 if (!i2c) mgag200_i2c_create()
123 i2c->data = data; mgag200_i2c_create()
124 i2c->clock = clock; mgag200_i2c_create()
125 i2c->adapter.owner = THIS_MODULE; mgag200_i2c_create()
126 i2c->adapter.class = I2C_CLASS_DDC; mgag200_i2c_create()
127 i2c->adapter.dev.parent = &dev->pdev->dev; mgag200_i2c_create()
128 i2c->dev = dev; mgag200_i2c_create()
129 i2c_set_adapdata(&i2c->adapter, i2c); mgag200_i2c_create()
130 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), "mga i2c"); mgag200_i2c_create()
132 i2c->adapter.algo_data = &i2c->bit; mgag200_i2c_create()
134 i2c->bit.udelay = 10; mgag200_i2c_create()
135 i2c->bit.timeout = 2; mgag200_i2c_create()
136 i2c->bit.data = i2c; mgag200_i2c_create()
137 i2c->bit.setsda = mga_gpio_setsda; mgag200_i2c_create()
138 i2c->bit.setscl = mga_gpio_setscl; mgag200_i2c_create()
139 i2c->bit.getsda = mga_gpio_getsda; mgag200_i2c_create()
140 i2c->bit.getscl = mga_gpio_getscl; mgag200_i2c_create()
142 ret = i2c_bit_add_bus(&i2c->adapter); mgag200_i2c_create()
144 kfree(i2c); mgag200_i2c_create()
145 i2c = NULL; mgag200_i2c_create()
147 return i2c; mgag200_i2c_create()
150 void mgag200_i2c_destroy(struct mga_i2c_chan *i2c) mgag200_i2c_destroy() argument
152 if (!i2c) mgag200_i2c_destroy()
154 i2c_del_adapter(&i2c->adapter); mgag200_i2c_destroy()
155 kfree(i2c); mgag200_i2c_destroy()
/linux-4.4.14/drivers/mfd/
H A D88pm860x-i2c.c14 #include <linux/i2c.h>
18 int pm860x_reg_read(struct i2c_client *i2c, int reg) pm860x_reg_read() argument
20 struct pm860x_chip *chip = i2c_get_clientdata(i2c); pm860x_reg_read()
21 struct regmap *map = (i2c == chip->client) ? chip->regmap pm860x_reg_read()
34 int pm860x_reg_write(struct i2c_client *i2c, int reg, pm860x_reg_write() argument
37 struct pm860x_chip *chip = i2c_get_clientdata(i2c); pm860x_reg_write()
38 struct regmap *map = (i2c == chip->client) ? chip->regmap pm860x_reg_write()
47 int pm860x_bulk_read(struct i2c_client *i2c, int reg, pm860x_bulk_read() argument
50 struct pm860x_chip *chip = i2c_get_clientdata(i2c); pm860x_bulk_read()
51 struct regmap *map = (i2c == chip->client) ? chip->regmap pm860x_bulk_read()
60 int pm860x_bulk_write(struct i2c_client *i2c, int reg, pm860x_bulk_write() argument
63 struct pm860x_chip *chip = i2c_get_clientdata(i2c); pm860x_bulk_write()
64 struct regmap *map = (i2c == chip->client) ? chip->regmap pm860x_bulk_write()
73 int pm860x_set_bits(struct i2c_client *i2c, int reg, pm860x_set_bits() argument
76 struct pm860x_chip *chip = i2c_get_clientdata(i2c); pm860x_set_bits()
77 struct regmap *map = (i2c == chip->client) ? chip->regmap pm860x_set_bits()
86 static int read_device(struct i2c_client *i2c, int reg, read_device() argument
91 struct i2c_adapter *adap = i2c->adapter; read_device()
94 .addr = i2c->addr, read_device()
99 { .addr = i2c->addr, read_device()
122 static int write_device(struct i2c_client *i2c, int reg, write_device() argument
126 struct i2c_adapter *adap = i2c->adapter; write_device()
132 msg.addr = i2c->addr; write_device()
143 int pm860x_page_reg_write(struct i2c_client *i2c, int reg, pm860x_page_reg_write() argument
149 i2c_lock_adapter(i2c->adapter); pm860x_page_reg_write()
150 read_device(i2c, 0xFA, 0, &zero); pm860x_page_reg_write()
151 read_device(i2c, 0xFB, 0, &zero); pm860x_page_reg_write()
152 read_device(i2c, 0xFF, 0, &zero); pm860x_page_reg_write()
153 ret = write_device(i2c, reg, 1, &data); pm860x_page_reg_write()
154 read_device(i2c, 0xFE, 0, &zero); pm860x_page_reg_write()
155 read_device(i2c, 0xFC, 0, &zero); pm860x_page_reg_write()
156 i2c_unlock_adapter(i2c->adapter); pm860x_page_reg_write()
161 int pm860x_page_bulk_read(struct i2c_client *i2c, int reg, pm860x_page_bulk_read() argument
167 i2c_lock_adapter(i2c->adapter); pm860x_page_bulk_read()
168 read_device(i2c, 0xfa, 0, &zero); pm860x_page_bulk_read()
169 read_device(i2c, 0xfb, 0, &zero); pm860x_page_bulk_read()
170 read_device(i2c, 0xff, 0, &zero); pm860x_page_bulk_read()
171 ret = read_device(i2c, reg, count, buf); pm860x_page_bulk_read()
172 read_device(i2c, 0xFE, 0, &zero); pm860x_page_bulk_read()
173 read_device(i2c, 0xFC, 0, &zero); pm860x_page_bulk_read()
174 i2c_unlock_adapter(i2c->adapter); pm860x_page_bulk_read()
H A Dwm8350-i2c.c2 * wm8350-i2c.c -- Generic I2C driver for Wolfson WM8350 PMIC
20 #include <linux/i2c.h>
26 static int wm8350_i2c_probe(struct i2c_client *i2c, wm8350_i2c_probe() argument
30 struct wm8350_platform_data *pdata = dev_get_platdata(&i2c->dev); wm8350_i2c_probe()
33 wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL); wm8350_i2c_probe()
37 wm8350->regmap = devm_regmap_init_i2c(i2c, &wm8350_regmap); wm8350_i2c_probe()
40 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", wm8350_i2c_probe()
45 i2c_set_clientdata(i2c, wm8350); wm8350_i2c_probe()
46 wm8350->dev = &i2c->dev; wm8350_i2c_probe()
48 return wm8350_device_init(wm8350, i2c->irq, pdata); wm8350_i2c_probe()
51 static int wm8350_i2c_remove(struct i2c_client *i2c) wm8350_i2c_remove() argument
53 struct wm8350 *wm8350 = i2c_get_clientdata(i2c); wm8350_i2c_remove()
66 MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id);
H A Darizona-i2c.c2 * Arizona-i2c.c -- Arizona I2C bus interface
14 #include <linux/i2c.h>
26 static int arizona_i2c_probe(struct i2c_client *i2c, arizona_i2c_probe() argument
34 if (i2c->dev.of_node) arizona_i2c_probe()
35 type = arizona_of_get_type(&i2c->dev); arizona_i2c_probe()
59 dev_err(&i2c->dev, "Unknown device type %ld\n", type); arizona_i2c_probe()
64 dev_err(&i2c->dev, arizona_i2c_probe()
69 arizona = devm_kzalloc(&i2c->dev, sizeof(*arizona), GFP_KERNEL); arizona_i2c_probe()
73 arizona->regmap = devm_regmap_init_i2c(i2c, regmap_config); arizona_i2c_probe()
76 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", arizona_i2c_probe()
82 arizona->dev = &i2c->dev; arizona_i2c_probe()
83 arizona->irq = i2c->irq; arizona_i2c_probe()
88 static int arizona_i2c_remove(struct i2c_client *i2c) arizona_i2c_remove() argument
90 struct arizona *arizona = dev_get_drvdata(&i2c->dev); arizona_i2c_remove()
104 MODULE_DEVICE_TABLE(i2c, arizona_i2c_id);
H A Dsmsc-ece1099.c17 #include <linux/i2c.h>
34 static int smsc_i2c_probe(struct i2c_client *i2c, smsc_i2c_probe() argument
41 smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc), smsc_i2c_probe()
44 dev_err(&i2c->dev, "smsc mfd driver memory allocation failed\n"); smsc_i2c_probe()
48 smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config); smsc_i2c_probe()
54 i2c_set_clientdata(i2c, smsc); smsc_i2c_probe()
55 smsc->dev = &i2c->dev; smsc_i2c_probe()
58 of_property_read_u32(i2c->dev.of_node, "clock", &smsc->clk); smsc_i2c_probe()
66 dev_info(&i2c->dev, "SMSCxxx devid: %02x rev: %02x venid: %02x\n", smsc_i2c_probe()
74 if (i2c->dev.of_node) smsc_i2c_probe()
75 ret = of_platform_populate(i2c->dev.of_node, smsc_i2c_probe()
76 NULL, NULL, &i2c->dev); smsc_i2c_probe()
83 static int smsc_i2c_remove(struct i2c_client *i2c) smsc_i2c_remove() argument
85 struct smsc *smsc = i2c_get_clientdata(i2c); smsc_i2c_remove()
96 MODULE_DEVICE_TABLE(i2c, smsc_i2c_id);
H A Dstmpe-i2c.c2 * ST Microelectronics MFD: stmpe's i2c client specific driver
12 #include <linux/i2c.h>
22 struct i2c_client *i2c = stmpe->client; i2c_reg_read() local
24 return i2c_smbus_read_byte_data(i2c, reg); i2c_reg_read()
29 struct i2c_client *i2c = stmpe->client; i2c_reg_write() local
31 return i2c_smbus_write_byte_data(i2c, reg, val); i2c_reg_write()
36 struct i2c_client *i2c = stmpe->client; i2c_block_read() local
38 return i2c_smbus_read_i2c_block_data(i2c, reg, length, values); i2c_block_read()
44 struct i2c_client *i2c = stmpe->client; i2c_block_write() local
46 return i2c_smbus_write_i2c_block_data(i2c, reg, length, values); i2c_block_write()
69 stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) stmpe_i2c_probe() argument
75 i2c_ci.irq = i2c->irq; stmpe_i2c_probe()
76 i2c_ci.client = i2c; stmpe_i2c_probe()
77 i2c_ci.dev = &i2c->dev; stmpe_i2c_probe()
79 of_id = of_match_device(stmpe_of_match, &i2c->dev); stmpe_i2c_probe()
85 dev_info(&i2c->dev, "matching on node name, compatible is preferred\n"); stmpe_i2c_probe()
93 static int stmpe_i2c_remove(struct i2c_client *i2c) stmpe_i2c_remove() argument
95 struct stmpe *stmpe = dev_get_drvdata(&i2c->dev); stmpe_i2c_remove()
110 MODULE_DEVICE_TABLE(i2c, stmpe_id);
114 .name = "stmpe-i2c",
H A Dmax77843.c15 #include <linux/i2c.h>
79 max77843->i2c_chg = i2c_new_dummy(max77843->i2c->adapter, I2C_ADDR_CHG); max77843_chg_init()
81 dev_err(&max77843->i2c->dev, max77843_chg_init()
102 static int max77843_probe(struct i2c_client *i2c, max77843_probe() argument
109 max77843 = devm_kzalloc(&i2c->dev, sizeof(*max77843), GFP_KERNEL); max77843_probe()
113 i2c_set_clientdata(i2c, max77843); max77843_probe()
114 max77843->dev = &i2c->dev; max77843_probe()
115 max77843->i2c = i2c; max77843_probe()
116 max77843->irq = i2c->irq; max77843_probe()
119 max77843->regmap = devm_regmap_init_i2c(i2c, max77843_probe()
122 dev_err(&i2c->dev, "Failed to allocate topsys register map\n"); max77843_probe()
130 dev_err(&i2c->dev, "Failed to add TOPSYS IRQ chip\n"); max77843_probe()
137 dev_err(&i2c->dev, "Failed to read PMIC ID\n"); max77843_probe()
140 dev_info(&i2c->dev, "device ID: 0x%x\n", reg_data); max77843_probe()
144 dev_err(&i2c->dev, "Failed to init Charger\n"); max77843_probe()
153 dev_err(&i2c->dev, "Failed to unmask interrupt source\n"); max77843_probe()
160 dev_err(&i2c->dev, "Failed to add mfd device\n"); max77843_probe()
174 static int max77843_remove(struct i2c_client *i2c) max77843_remove() argument
176 struct max77693_dev *max77843 = i2c_get_clientdata(i2c); max77843_remove()
196 MODULE_DEVICE_TABLE(i2c, max77843_id);
200 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max77843_suspend() local
201 struct max77693_dev *max77843 = i2c_get_clientdata(i2c); max77843_suspend()
212 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max77843_resume() local
213 struct max77693_dev *max77843 = i2c_get_clientdata(i2c); max77843_resume()
H A Dmax8997.c26 #include <linux/i2c.h>
61 int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) max8997_read_reg() argument
63 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_read_reg()
67 ret = i2c_smbus_read_byte_data(i2c, reg); max8997_read_reg()
78 int max8997_bulk_read(struct i2c_client *i2c, u8 reg, int count, u8 *buf) max8997_bulk_read() argument
80 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_bulk_read()
84 ret = i2c_smbus_read_i2c_block_data(i2c, reg, count, buf); max8997_bulk_read()
93 int max8997_write_reg(struct i2c_client *i2c, u8 reg, u8 value) max8997_write_reg() argument
95 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_write_reg()
99 ret = i2c_smbus_write_byte_data(i2c, reg, value); max8997_write_reg()
105 int max8997_bulk_write(struct i2c_client *i2c, u8 reg, int count, u8 *buf) max8997_bulk_write() argument
107 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_bulk_write()
111 ret = i2c_smbus_write_i2c_block_data(i2c, reg, count, buf); max8997_bulk_write()
120 int max8997_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask) max8997_update_reg() argument
122 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_update_reg()
126 ret = i2c_smbus_read_byte_data(i2c, reg); max8997_update_reg()
130 ret = i2c_smbus_write_byte_data(i2c, reg, new_val); max8997_update_reg()
168 static inline unsigned long max8997_i2c_get_driver_data(struct i2c_client *i2c, max8997_i2c_get_driver_data() argument
171 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { max8997_i2c_get_driver_data()
173 match = of_match_node(max8997_pmic_dt_match, i2c->dev.of_node); max8997_i2c_get_driver_data()
179 static int max8997_i2c_probe(struct i2c_client *i2c, max8997_i2c_probe() argument
183 struct max8997_platform_data *pdata = dev_get_platdata(&i2c->dev); max8997_i2c_probe()
186 max8997 = devm_kzalloc(&i2c->dev, sizeof(struct max8997_dev), max8997_i2c_probe()
191 i2c_set_clientdata(i2c, max8997); max8997_i2c_probe()
192 max8997->dev = &i2c->dev; max8997_i2c_probe()
193 max8997->i2c = i2c; max8997_i2c_probe()
194 max8997->type = max8997_i2c_get_driver_data(i2c, id); max8997_i2c_probe()
195 max8997->irq = i2c->irq; max8997_i2c_probe()
211 max8997->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC); max8997_i2c_probe()
218 max8997->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); max8997_i2c_probe()
226 max8997->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); max8997_i2c_probe()
266 static int max8997_i2c_remove(struct i2c_client *i2c) max8997_i2c_remove() argument
268 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_i2c_remove()
283 MODULE_DEVICE_TABLE(i2c, max8998_i2c_id);
440 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8997_freeze() local
441 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_freeze()
445 max8997_read_reg(i2c, max8997_dumpaddr_pmic[i], max8997_freeze()
449 max8997_read_reg(i2c, max8997_dumpaddr_muic[i], max8997_freeze()
453 max8997_read_reg(i2c, max8997_dumpaddr_haptic[i], max8997_freeze()
462 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8997_restore() local
463 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_restore()
467 max8997_write_reg(i2c, max8997_dumpaddr_pmic[i], max8997_restore()
471 max8997_write_reg(i2c, max8997_dumpaddr_muic[i], max8997_restore()
475 max8997_write_reg(i2c, max8997_dumpaddr_haptic[i], max8997_restore()
484 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8997_suspend() local
485 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_suspend()
494 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8997_resume() local
495 struct max8997_dev *max8997 = i2c_get_clientdata(i2c); max8997_resume()
H A Drn5t618.c14 #include <linux/i2c.h>
62 static int rn5t618_i2c_probe(struct i2c_client *i2c, rn5t618_i2c_probe() argument
68 priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); rn5t618_i2c_probe()
72 i2c_set_clientdata(i2c, priv); rn5t618_i2c_probe()
74 priv->regmap = devm_regmap_init_i2c(i2c, &rn5t618_regmap_config); rn5t618_i2c_probe()
77 dev_err(&i2c->dev, "regmap init failed: %d\n", ret); rn5t618_i2c_probe()
81 ret = mfd_add_devices(&i2c->dev, -1, rn5t618_cells, rn5t618_i2c_probe()
84 dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret); rn5t618_i2c_probe()
96 static int rn5t618_i2c_remove(struct i2c_client *i2c) rn5t618_i2c_remove() argument
98 struct rn5t618 *priv = i2c_get_clientdata(i2c); rn5t618_i2c_remove()
105 mfd_remove_devices(&i2c->dev); rn5t618_i2c_remove()
118 MODULE_DEVICE_TABLE(i2c, rn5t618_i2c_id);
H A Dtps65912-i2c.c2 * tps65912-i2c.c -- I2C access for TI TPS65912x PMIC
21 #include <linux/i2c.h>
28 struct i2c_client *i2c = tps65912->control_data; tps65912_i2c_read() local
33 xfer[0].addr = i2c->addr; tps65912_i2c_read()
39 xfer[1].addr = i2c->addr; tps65912_i2c_read()
44 ret = i2c_transfer(i2c->adapter, xfer, 2); tps65912_i2c_read()
55 struct i2c_client *i2c = tps65912->control_data; tps65912_i2c_write() local
66 ret = i2c_master_send(i2c, msg, bytes + 1); tps65912_i2c_write()
75 static int tps65912_i2c_probe(struct i2c_client *i2c, tps65912_i2c_probe() argument
80 tps65912 = devm_kzalloc(&i2c->dev, tps65912_i2c_probe()
85 i2c_set_clientdata(i2c, tps65912); tps65912_i2c_probe()
86 tps65912->dev = &i2c->dev; tps65912_i2c_probe()
87 tps65912->control_data = i2c; tps65912_i2c_probe()
94 static int tps65912_i2c_remove(struct i2c_client *i2c) tps65912_i2c_remove() argument
96 struct tps65912 *tps65912 = i2c_get_clientdata(i2c); tps65912_i2c_remove()
107 MODULE_DEVICE_TABLE(i2c, tps65912_i2c_id);
H A Dmax8998.c28 #include <linux/i2c.h>
58 int max8998_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest) max8998_read_reg() argument
60 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_read_reg()
64 ret = i2c_smbus_read_byte_data(i2c, reg); max8998_read_reg()
75 int max8998_bulk_read(struct i2c_client *i2c, u8 reg, int count, u8 *buf) max8998_bulk_read() argument
77 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_bulk_read()
81 ret = i2c_smbus_read_i2c_block_data(i2c, reg, count, buf); max8998_bulk_read()
90 int max8998_write_reg(struct i2c_client *i2c, u8 reg, u8 value) max8998_write_reg() argument
92 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_write_reg()
96 ret = i2c_smbus_write_byte_data(i2c, reg, value); max8998_write_reg()
102 int max8998_bulk_write(struct i2c_client *i2c, u8 reg, int count, u8 *buf) max8998_bulk_write() argument
104 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_bulk_write()
108 ret = i2c_smbus_write_i2c_block_data(i2c, reg, count, buf); max8998_bulk_write()
117 int max8998_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask) max8998_update_reg() argument
119 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_update_reg()
123 ret = i2c_smbus_read_byte_data(i2c, reg); max8998_update_reg()
127 ret = i2c_smbus_write_byte_data(i2c, reg, new_val); max8998_update_reg()
172 static inline unsigned long max8998_i2c_get_driver_data(struct i2c_client *i2c, max8998_i2c_get_driver_data() argument
175 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { max8998_i2c_get_driver_data()
177 match = of_match_node(max8998_dt_match, i2c->dev.of_node); max8998_i2c_get_driver_data()
184 static int max8998_i2c_probe(struct i2c_client *i2c, max8998_i2c_probe() argument
187 struct max8998_platform_data *pdata = dev_get_platdata(&i2c->dev); max8998_i2c_probe()
191 max8998 = devm_kzalloc(&i2c->dev, sizeof(struct max8998_dev), max8998_i2c_probe()
196 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { max8998_i2c_probe()
197 pdata = max8998_i2c_parse_dt_pdata(&i2c->dev); max8998_i2c_probe()
204 i2c_set_clientdata(i2c, max8998); max8998_i2c_probe()
205 max8998->dev = &i2c->dev; max8998_i2c_probe()
206 max8998->i2c = i2c; max8998_i2c_probe()
207 max8998->irq = i2c->irq; max8998_i2c_probe()
208 max8998->type = max8998_i2c_get_driver_data(i2c, id); max8998_i2c_probe()
217 max8998->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR); max8998_i2c_probe()
219 dev_err(&i2c->dev, "Failed to allocate I2C device for RTC\n"); max8998_i2c_probe()
257 static int max8998_i2c_remove(struct i2c_client *i2c) max8998_i2c_remove() argument
259 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_i2c_remove()
273 MODULE_DEVICE_TABLE(i2c, max8998_i2c_id);
277 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8998_suspend() local
278 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_suspend()
287 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8998_resume() local
288 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); max8998_resume()
297 return max8998_irq_resume(i2c_get_clientdata(i2c)); max8998_resume()
347 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8998_freeze() local
351 max8998_read_reg(i2c, max8998_dump[i].addr, max8998_freeze()
360 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max8998_restore() local
364 max8998_write_reg(i2c, max8998_dump[i].addr, max8998_restore()
H A Dtps6507x.c21 #include <linux/i2c.h>
40 struct i2c_client *i2c = tps6507x->i2c_client; tps6507x_i2c_read_device() local
45 xfer[0].addr = i2c->addr; tps6507x_i2c_read_device()
51 xfer[1].addr = i2c->addr; tps6507x_i2c_read_device()
56 ret = i2c_transfer(i2c->adapter, xfer, 2); tps6507x_i2c_read_device()
68 struct i2c_client *i2c = tps6507x->i2c_client; tps6507x_i2c_write_device() local
79 ret = i2c_master_send(i2c, msg, bytes + 1); tps6507x_i2c_write_device()
87 static int tps6507x_i2c_probe(struct i2c_client *i2c, tps6507x_i2c_probe() argument
92 tps6507x = devm_kzalloc(&i2c->dev, sizeof(struct tps6507x_dev), tps6507x_i2c_probe()
97 i2c_set_clientdata(i2c, tps6507x); tps6507x_i2c_probe()
98 tps6507x->dev = &i2c->dev; tps6507x_i2c_probe()
99 tps6507x->i2c_client = i2c; tps6507x_i2c_probe()
107 static int tps6507x_i2c_remove(struct i2c_client *i2c) tps6507x_i2c_remove() argument
109 struct tps6507x_dev *tps6507x = i2c_get_clientdata(i2c); tps6507x_i2c_remove()
119 MODULE_DEVICE_TABLE(i2c, tps6507x_i2c_id);
H A Dda9055-i2c.c16 #include <linux/i2c.h>
23 static int da9055_i2c_probe(struct i2c_client *i2c, da9055_i2c_probe() argument
29 da9055 = devm_kzalloc(&i2c->dev, sizeof(struct da9055), GFP_KERNEL); da9055_i2c_probe()
33 da9055->regmap = devm_regmap_init_i2c(i2c, &da9055_regmap_config); da9055_i2c_probe()
36 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", da9055_i2c_probe()
41 da9055->dev = &i2c->dev; da9055_i2c_probe()
42 da9055->chip_irq = i2c->irq; da9055_i2c_probe()
44 i2c_set_clientdata(i2c, da9055); da9055_i2c_probe()
49 static int da9055_i2c_remove(struct i2c_client *i2c) da9055_i2c_remove() argument
51 struct da9055 *da9055 = i2c_get_clientdata(i2c); da9055_i2c_remove()
69 MODULE_DEVICE_TABLE(i2c, da9055_i2c_id);
H A Dwm831x-i2c.c2 * wm831x-i2c.c -- I2C access for Wolfson WM831x PMICs
17 #include <linux/i2c.h>
27 static int wm831x_i2c_probe(struct i2c_client *i2c, wm831x_i2c_probe() argument
33 wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL); wm831x_i2c_probe()
37 i2c_set_clientdata(i2c, wm831x); wm831x_i2c_probe()
38 wm831x->dev = &i2c->dev; wm831x_i2c_probe()
40 wm831x->regmap = devm_regmap_init_i2c(i2c, &wm831x_regmap_config); wm831x_i2c_probe()
48 return wm831x_device_init(wm831x, id->driver_data, i2c->irq); wm831x_i2c_probe()
51 static int wm831x_i2c_remove(struct i2c_client *i2c) wm831x_i2c_remove() argument
53 struct wm831x *wm831x = i2c_get_clientdata(i2c); wm831x_i2c_remove()
86 MODULE_DEVICE_TABLE(i2c, wm831x_i2c_id);
H A Drt5033.c62 static int rt5033_i2c_probe(struct i2c_client *i2c, rt5033_i2c_probe() argument
69 rt5033 = devm_kzalloc(&i2c->dev, sizeof(*rt5033), GFP_KERNEL); rt5033_i2c_probe()
73 i2c_set_clientdata(i2c, rt5033); rt5033_i2c_probe()
74 rt5033->dev = &i2c->dev; rt5033_i2c_probe()
75 rt5033->irq = i2c->irq; rt5033_i2c_probe()
78 rt5033->regmap = devm_regmap_init_i2c(i2c, &rt5033_regmap_config); rt5033_i2c_probe()
80 dev_err(&i2c->dev, "Failed to allocate register map.\n"); rt5033_i2c_probe()
86 dev_err(&i2c->dev, "Device not found\n"); rt5033_i2c_probe()
89 dev_info(&i2c->dev, "Device found Device ID: %04x\n", dev_id); rt5033_i2c_probe()
95 dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n", rt5033_i2c_probe()
104 dev_err(&i2c->dev, "Failed to add RT5033 child devices.\n"); rt5033_i2c_probe()
113 static int rt5033_i2c_remove(struct i2c_client *i2c) rt5033_i2c_remove() argument
115 mfd_remove_devices(&i2c->dev); rt5033_i2c_remove()
124 MODULE_DEVICE_TABLE(i2c, rt5033_i2c_id);
H A Dmax8925-i2c.c14 #include <linux/i2c.h>
21 static inline int max8925_read_device(struct i2c_client *i2c, max8925_read_device() argument
27 ret = i2c_smbus_read_i2c_block_data(i2c, reg, bytes, dest); max8925_read_device()
29 ret = i2c_smbus_read_byte_data(i2c, reg); max8925_read_device()
37 static inline int max8925_write_device(struct i2c_client *i2c, max8925_write_device() argument
46 ret = i2c_master_send(i2c, buf, bytes + 1); max8925_write_device()
52 int max8925_reg_read(struct i2c_client *i2c, int reg) max8925_reg_read() argument
54 struct max8925_chip *chip = i2c_get_clientdata(i2c); max8925_reg_read()
59 ret = max8925_read_device(i2c, reg, 1, &data); max8925_reg_read()
69 int max8925_reg_write(struct i2c_client *i2c, int reg, max8925_reg_write() argument
72 struct max8925_chip *chip = i2c_get_clientdata(i2c); max8925_reg_write()
76 ret = max8925_write_device(i2c, reg, 1, &data); max8925_reg_write()
83 int max8925_bulk_read(struct i2c_client *i2c, int reg, max8925_bulk_read() argument
86 struct max8925_chip *chip = i2c_get_clientdata(i2c); max8925_bulk_read()
90 ret = max8925_read_device(i2c, reg, count, buf); max8925_bulk_read()
97 int max8925_bulk_write(struct i2c_client *i2c, int reg, max8925_bulk_write() argument
100 struct max8925_chip *chip = i2c_get_clientdata(i2c); max8925_bulk_write()
104 ret = max8925_write_device(i2c, reg, count, buf); max8925_bulk_write()
111 int max8925_set_bits(struct i2c_client *i2c, int reg, max8925_set_bits() argument
114 struct max8925_chip *chip = i2c_get_clientdata(i2c); max8925_set_bits()
119 ret = max8925_read_device(i2c, reg, 1, &value); max8925_set_bits()
124 ret = max8925_write_device(i2c, reg, 1, &value); max8925_set_bits()
136 MODULE_DEVICE_TABLE(i2c, max8925_id_table);
177 chip->i2c = client; max8925_probe()
183 chip->rtc = i2c_new_dummy(chip->i2c->adapter, RTC_I2C_ADDR); max8925_probe()
190 chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR); max8925_probe()
H A Das3722.c26 #include <linux/i2c.h>
331 static int as3722_i2c_of_probe(struct i2c_client *i2c, as3722_i2c_of_probe() argument
334 struct device_node *np = i2c->dev.of_node; as3722_i2c_of_probe()
338 dev_err(&i2c->dev, "Device Tree not found\n"); as3722_i2c_of_probe()
342 irq_data = irq_get_irq_data(i2c->irq); as3722_i2c_of_probe()
344 dev_err(&i2c->dev, "Invalid IRQ: %d\n", i2c->irq); as3722_i2c_of_probe()
351 "ams,enable-internal-i2c-pullup"); as3722_i2c_of_probe()
353 dev_dbg(&i2c->dev, "IRQ flags are 0x%08lx\n", as3722->irq_flags); as3722_i2c_of_probe()
357 static int as3722_i2c_probe(struct i2c_client *i2c, as3722_i2c_probe() argument
364 as3722 = devm_kzalloc(&i2c->dev, sizeof(struct as3722), GFP_KERNEL); as3722_i2c_probe()
368 as3722->dev = &i2c->dev; as3722_i2c_probe()
369 as3722->chip_irq = i2c->irq; as3722_i2c_probe()
370 i2c_set_clientdata(i2c, as3722); as3722_i2c_probe()
372 ret = as3722_i2c_of_probe(i2c, as3722); as3722_i2c_probe()
376 as3722->regmap = devm_regmap_init_i2c(i2c, &as3722_regmap_config); as3722_i2c_probe()
379 dev_err(&i2c->dev, "regmap init failed: %d\n", ret); as3722_i2c_probe()
400 ret = mfd_add_devices(&i2c->dev, -1, as3722_devs, as3722_i2c_probe()
416 static int as3722_i2c_remove(struct i2c_client *i2c) as3722_i2c_remove() argument
418 struct as3722 *as3722 = i2c_get_clientdata(i2c); as3722_i2c_remove()
435 MODULE_DEVICE_TABLE(i2c, as3722_i2c_id);
H A Dmax8907.c13 #include <linux/i2c.h>
187 static int max8907_i2c_probe(struct i2c_client *i2c, max8907_i2c_probe() argument
192 struct max8907_platform_data *pdata = dev_get_platdata(&i2c->dev); max8907_i2c_probe()
197 else if (i2c->dev.of_node) max8907_i2c_probe()
198 pm_off = of_property_read_bool(i2c->dev.of_node, max8907_i2c_probe()
201 max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL); max8907_i2c_probe()
207 max8907->dev = &i2c->dev; max8907_i2c_probe()
210 max8907->i2c_gen = i2c; max8907_i2c_probe()
211 i2c_set_clientdata(i2c, max8907); max8907_i2c_probe()
212 max8907->regmap_gen = devm_regmap_init_i2c(i2c, max8907_i2c_probe()
216 dev_err(&i2c->dev, "gen regmap init failed: %d\n", ret); max8907_i2c_probe()
220 max8907->i2c_rtc = i2c_new_dummy(i2c->adapter, MAX8907_RTC_I2C_ADDR); max8907_i2c_probe()
230 dev_err(&i2c->dev, "rtc regmap init failed: %d\n", ret); max8907_i2c_probe()
241 dev_err(&i2c->dev, "failed to add chg irq chip: %d\n", ret); max8907_i2c_probe()
249 dev_err(&i2c->dev, "failed to add on off irq chip: %d\n", ret); max8907_i2c_probe()
257 dev_err(&i2c->dev, "failed to add rtc irq chip: %d\n", ret); max8907_i2c_probe()
266 dev_err(&i2c->dev, "failed to add MFD devices %d\n", ret); max8907_i2c_probe()
292 static int max8907_i2c_remove(struct i2c_client *i2c) max8907_i2c_remove() argument
294 struct max8907 *max8907 = i2c_get_clientdata(i2c); max8907_i2c_remove()
319 MODULE_DEVICE_TABLE(i2c, max8907_i2c_id);
H A Dretu-mfd.c20 #include <linux/i2c.h>
194 struct i2c_client *i2c = to_i2c_client(dev); retu_regmap_read() local
198 ret = i2c_smbus_read_word_data(i2c, *(u8 const *)reg); retu_regmap_read()
211 struct i2c_client *i2c = to_i2c_client(dev); retu_regmap_write() local
216 return i2c_smbus_write_word_data(i2c, reg, val); retu_regmap_write()
230 static int retu_probe(struct i2c_client *i2c, const struct i2c_device_id *id) retu_probe() argument
236 if (i2c->addr > ARRAY_SIZE(retu_data)) retu_probe()
238 rdat = &retu_data[i2c->addr - 1]; retu_probe()
240 rdev = devm_kzalloc(&i2c->dev, sizeof(*rdev), GFP_KERNEL); retu_probe()
244 i2c_set_clientdata(i2c, rdev); retu_probe()
245 rdev->dev = &i2c->dev; retu_probe()
247 rdev->regmap = devm_regmap_init(&i2c->dev, &retu_bus, &i2c->dev, retu_probe()
269 ret = regmap_add_irq_chip(rdev->regmap, i2c->irq, IRQF_ONESHOT, -1, retu_probe()
278 regmap_del_irq_chip(i2c->irq, rdev->irq_data); retu_probe()
282 if (i2c->addr == 1 && !pm_power_off) { retu_probe()
290 static int retu_remove(struct i2c_client *i2c) retu_remove() argument
292 struct retu_dev *rdev = i2c_get_clientdata(i2c); retu_remove()
299 regmap_del_irq_chip(i2c->irq, rdev->irq_data); retu_remove()
309 MODULE_DEVICE_TABLE(i2c, retu_id);
H A Dda9063-i2c.c1 /* da9063-i2c.c: Interrupt support for Dialog DA9063
17 #include <linux/i2c.h>
214 static int da9063_i2c_probe(struct i2c_client *i2c, da9063_i2c_probe() argument
220 da9063 = devm_kzalloc(&i2c->dev, sizeof(struct da9063), GFP_KERNEL); da9063_i2c_probe()
224 i2c_set_clientdata(i2c, da9063); da9063_i2c_probe()
225 da9063->dev = &i2c->dev; da9063_i2c_probe()
226 da9063->chip_irq = i2c->irq; da9063_i2c_probe()
238 da9063->regmap = devm_regmap_init_i2c(i2c, &da9063_regmap_config); da9063_i2c_probe()
246 return da9063_device_init(da9063, i2c->irq); da9063_i2c_probe()
249 static int da9063_i2c_remove(struct i2c_client *i2c) da9063_i2c_remove() argument
251 struct da9063 *da9063 = i2c_get_clientdata(i2c); da9063_i2c_remove()
262 MODULE_DEVICE_TABLE(i2c, da9063_i2c_id);
H A Dsec-core.c19 #include <linux/i2c.h>
324 static inline unsigned long sec_i2c_get_driver_data(struct i2c_client *i2c, sec_i2c_get_driver_data() argument
328 if (i2c->dev.of_node) { sec_i2c_get_driver_data()
331 match = of_match_node(sec_dt_match, i2c->dev.of_node); sec_i2c_get_driver_data()
338 static int sec_pmic_probe(struct i2c_client *i2c, sec_pmic_probe() argument
341 struct sec_platform_data *pdata = dev_get_platdata(&i2c->dev); sec_pmic_probe()
348 sec_pmic = devm_kzalloc(&i2c->dev, sizeof(struct sec_pmic_dev), sec_pmic_probe()
353 i2c_set_clientdata(i2c, sec_pmic); sec_pmic_probe()
354 sec_pmic->dev = &i2c->dev; sec_pmic_probe()
355 sec_pmic->i2c = i2c; sec_pmic_probe()
356 sec_pmic->irq = i2c->irq; sec_pmic_probe()
357 device_type = sec_i2c_get_driver_data(i2c, id); sec_pmic_probe()
401 sec_pmic->regmap_pmic = devm_regmap_init_i2c(i2c, regmap); sec_pmic_probe()
404 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", sec_pmic_probe()
469 static int sec_pmic_remove(struct i2c_client *i2c) sec_pmic_remove() argument
471 struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); sec_pmic_remove()
478 static void sec_pmic_shutdown(struct i2c_client *i2c) sec_pmic_shutdown() argument
480 struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); sec_pmic_shutdown()
508 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); sec_pmic_suspend() local
509 struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); sec_pmic_suspend()
529 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); sec_pmic_resume() local
530 struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); sec_pmic_resume()
546 MODULE_DEVICE_TABLE(i2c, sec_pmic_id);
H A Dintel_soc_pmic_core.c21 #include <linux/i2c.h>
63 static int intel_soc_pmic_i2c_probe(struct i2c_client *i2c, intel_soc_pmic_i2c_probe() argument
66 struct device *dev = &i2c->dev; intel_soc_pmic_i2c_probe()
85 pmic->regmap = devm_regmap_init_i2c(i2c, config->regmap_config); intel_soc_pmic_i2c_probe()
93 pmic->irq = (irq < 0) ? i2c->irq : irq; intel_soc_pmic_i2c_probe()
125 static int intel_soc_pmic_i2c_remove(struct i2c_client *i2c) intel_soc_pmic_i2c_remove() argument
127 struct intel_soc_pmic *pmic = dev_get_drvdata(&i2c->dev); intel_soc_pmic_i2c_remove()
137 mfd_remove_devices(&i2c->dev); intel_soc_pmic_i2c_remove()
142 static void intel_soc_pmic_shutdown(struct i2c_client *i2c) intel_soc_pmic_shutdown() argument
144 struct intel_soc_pmic *pmic = dev_get_drvdata(&i2c->dev); intel_soc_pmic_shutdown()
177 MODULE_DEVICE_TABLE(i2c, intel_soc_pmic_i2c_id);
H A Drc5t583.c30 #include <linux/i2c.h>
249 static int rc5t583_i2c_probe(struct i2c_client *i2c, rc5t583_i2c_probe() argument
253 struct rc5t583_platform_data *pdata = dev_get_platdata(&i2c->dev); rc5t583_i2c_probe()
258 dev_err(&i2c->dev, "Err: Platform data not found\n"); rc5t583_i2c_probe()
262 rc5t583 = devm_kzalloc(&i2c->dev, sizeof(struct rc5t583), GFP_KERNEL); rc5t583_i2c_probe()
264 dev_err(&i2c->dev, "Memory allocation failed\n"); rc5t583_i2c_probe()
268 rc5t583->dev = &i2c->dev; rc5t583_i2c_probe()
269 i2c_set_clientdata(i2c, rc5t583); rc5t583_i2c_probe()
271 rc5t583->regmap = devm_regmap_init_i2c(i2c, &rc5t583_regmap_config); rc5t583_i2c_probe()
274 dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); rc5t583_i2c_probe()
282 if (i2c->irq) { rc5t583_i2c_probe()
283 ret = rc5t583_irq_init(rc5t583, i2c->irq, pdata->irq_base); rc5t583_i2c_probe()
286 dev_warn(&i2c->dev, "IRQ init failed: %d\n", ret); rc5t583_i2c_probe()
294 dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret); rc5t583_i2c_probe()
306 static int rc5t583_i2c_remove(struct i2c_client *i2c) rc5t583_i2c_remove() argument
308 struct rc5t583 *rc5t583 = i2c_get_clientdata(i2c); rc5t583_i2c_remove()
320 MODULE_DEVICE_TABLE(i2c, rc5t583_i2c_id);
H A Dmax77686.c27 #include <linux/i2c.h>
208 static int max77686_i2c_probe(struct i2c_client *i2c, max77686_i2c_probe() argument
222 max77686 = devm_kzalloc(&i2c->dev, max77686_i2c_probe()
227 if (i2c->dev.of_node) { max77686_i2c_probe()
228 match = of_match_node(max77686_pmic_dt_match, i2c->dev.of_node); max77686_i2c_probe()
236 i2c_set_clientdata(i2c, max77686); max77686_i2c_probe()
237 max77686->dev = &i2c->dev; max77686_i2c_probe()
238 max77686->i2c = i2c; max77686_i2c_probe()
240 max77686->irq = i2c->irq; max77686_i2c_probe()
258 max77686->regmap = devm_regmap_init_i2c(i2c, config); max77686_i2c_probe()
274 max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC); max77686_i2c_probe()
299 dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret); max77686_i2c_probe()
308 dev_err(&i2c->dev, "failed to add RTC irq chip: %d\n", ret); max77686_i2c_probe()
314 dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret); max77686_i2c_probe()
331 static int max77686_i2c_remove(struct i2c_client *i2c) max77686_i2c_remove() argument
333 struct max77686_dev *max77686 = i2c_get_clientdata(i2c); max77686_i2c_remove()
350 MODULE_DEVICE_TABLE(i2c, max77686_i2c_id);
355 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max77686_suspend() local
356 struct max77686_dev *max77686 = i2c_get_clientdata(i2c); max77686_suspend()
377 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); max77686_resume() local
378 struct max77686_dev *max77686 = i2c_get_clientdata(i2c); max77686_resume()
H A Dwm8400-core.c18 #include <linux/i2c.h>
160 static int wm8400_i2c_probe(struct i2c_client *i2c, wm8400_i2c_probe() argument
165 wm8400 = devm_kzalloc(&i2c->dev, sizeof(struct wm8400), GFP_KERNEL); wm8400_i2c_probe()
169 wm8400->regmap = devm_regmap_init_i2c(i2c, &wm8400_regmap_config); wm8400_i2c_probe()
173 wm8400->dev = &i2c->dev; wm8400_i2c_probe()
174 i2c_set_clientdata(i2c, wm8400); wm8400_i2c_probe()
176 return wm8400_init(wm8400, dev_get_platdata(&i2c->dev)); wm8400_i2c_probe()
179 static int wm8400_i2c_remove(struct i2c_client *i2c) wm8400_i2c_remove() argument
181 struct wm8400 *wm8400 = i2c_get_clientdata(i2c); wm8400_i2c_remove()
192 MODULE_DEVICE_TABLE(i2c, wm8400_i2c_id);
H A Dtc3589x.c14 #include <linux/i2c.h>
46 ret = i2c_smbus_read_byte_data(tc3589x->i2c, reg); tc3589x_reg_read()
65 ret = i2c_smbus_write_byte_data(tc3589x->i2c, reg, data); tc3589x_reg_write()
85 ret = i2c_smbus_read_i2c_block_data(tc3589x->i2c, reg, length, values); tc3589x_block_read()
106 ret = i2c_smbus_write_i2c_block_data(tc3589x->i2c, reg, length, tc3589x_block_write()
355 static int tc3589x_probe(struct i2c_client *i2c, tc3589x_probe() argument
358 struct device_node *np = i2c->dev.of_node; tc3589x_probe()
359 struct tc3589x_platform_data *pdata = dev_get_platdata(&i2c->dev); tc3589x_probe()
365 pdata = tc3589x_of_probe(&i2c->dev, &version); tc3589x_probe()
367 dev_err(&i2c->dev, "No platform data or DT found\n"); tc3589x_probe()
375 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA tc3589x_probe()
379 tc3589x = devm_kzalloc(&i2c->dev, sizeof(struct tc3589x), tc3589x_probe()
386 tc3589x->dev = &i2c->dev; tc3589x_probe()
387 tc3589x->i2c = i2c; tc3589x_probe()
405 i2c_set_clientdata(i2c, tc3589x); tc3589x_probe()
415 ret = request_threaded_irq(tc3589x->i2c->irq, NULL, tc3589x_irq, tc3589x_probe()
445 struct i2c_client *client = tc3589x->i2c; tc3589x_suspend()
459 struct i2c_client *client = tc3589x->i2c; tc3589x_resume()
483 MODULE_DEVICE_TABLE(i2c, tc3589x_id);
H A Dpalmas.c19 #include <linux/i2c.h>
380 static int palmas_set_pdata_irq_flag(struct i2c_client *i2c, palmas_set_pdata_irq_flag() argument
383 struct irq_data *irq_data = irq_get_irq_data(i2c->irq); palmas_set_pdata_irq_flag()
385 dev_err(&i2c->dev, "Invalid IRQ: %d\n", i2c->irq); palmas_set_pdata_irq_flag()
390 dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags); palmas_set_pdata_irq_flag()
394 static void palmas_dt_to_pdata(struct i2c_client *i2c, palmas_dt_to_pdata() argument
397 struct device_node *node = i2c->dev.of_node; palmas_dt_to_pdata()
421 if (i2c->irq) palmas_dt_to_pdata()
422 palmas_set_pdata_irq_flag(i2c, pdata); palmas_dt_to_pdata()
491 static int palmas_i2c_probe(struct i2c_client *i2c, palmas_i2c_probe() argument
497 struct device_node *node = i2c->dev.of_node; palmas_i2c_probe()
503 pdata = dev_get_platdata(&i2c->dev); palmas_i2c_probe()
506 pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL); palmas_i2c_probe()
511 palmas_dt_to_pdata(i2c, pdata); palmas_i2c_probe()
517 palmas = devm_kzalloc(&i2c->dev, sizeof(struct palmas), GFP_KERNEL); palmas_i2c_probe()
521 i2c_set_clientdata(i2c, palmas); palmas_i2c_probe()
522 palmas->dev = &i2c->dev; palmas_i2c_probe()
523 palmas->irq = i2c->irq; palmas_i2c_probe()
525 match = of_match_device(of_palmas_match_tbl, &i2c->dev); palmas_i2c_probe()
535 palmas->i2c_clients[i] = i2c; palmas_i2c_probe()
538 i2c_new_dummy(i2c->adapter, palmas_i2c_probe()
539 i2c->addr + i); palmas_i2c_probe()
668 ret = of_platform_populate(node, NULL, NULL, &i2c->dev); palmas_i2c_probe()
689 static int palmas_i2c_remove(struct i2c_client *i2c) palmas_i2c_remove() argument
691 struct palmas *palmas = i2c_get_clientdata(i2c); palmas_i2c_remove()
716 MODULE_DEVICE_TABLE(i2c, palmas_i2c_id);
/linux-4.4.14/drivers/video/fbdev/mb862xx/
H A DMakefile8 mb862xxfb-$(CONFIG_FB_MB862XX_I2C) += mb862xx-i2c.o
H A Dmb862xx-i2c.c13 #include <linux/i2c.h>
28 reg = inreg(i2c, GC_I2C_BCR); mb862xx_i2c_wait_event()
40 outreg(i2c, GC_I2C_DAR, addr); mb862xx_i2c_do_address()
41 outreg(i2c, GC_I2C_CCR, I2C_CLOCK_AND_ENABLE); mb862xx_i2c_do_address()
42 outreg(i2c, GC_I2C_BCR, par->i2c_rs ? I2C_REPEATED_START : I2C_START); mb862xx_i2c_do_address()
45 par->i2c_rs = !(inreg(i2c, GC_I2C_BSR) & I2C_LRB); mb862xx_i2c_do_address()
53 outreg(i2c, GC_I2C_DAR, byte); mb862xx_i2c_write_byte()
54 outreg(i2c, GC_I2C_BCR, I2C_START); mb862xx_i2c_write_byte()
57 return !(inreg(i2c, GC_I2C_BSR) & I2C_LRB); mb862xx_i2c_write_byte()
64 outreg(i2c, GC_I2C_BCR, I2C_START | (last ? 0 : I2C_ACK)); mb862xx_i2c_read_byte()
67 *byte = inreg(i2c, GC_I2C_DAR); mb862xx_i2c_read_byte()
75 outreg(i2c, GC_I2C_BCR, I2C_STOP); mb862xx_i2c_stop()
76 outreg(i2c, GC_I2C_CCR, I2C_DISABLE); mb862xx_i2c_stop()
/linux-4.4.14/drivers/nfc/fdp/
H A DMakefile8 fdp_i2c-objs = i2c.o
/linux-4.4.14/arch/arm/plat-omap/
H A DMakefile14 i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
15 obj-y += $(i2c-omap-m) $(i2c-omap-y)
/linux-4.4.14/drivers/video/fbdev/aty/
H A Dradeon_i2c.c9 #include <linux/i2c.h>
10 #include <linux/i2c-algo-bit.h>
101 rinfo->i2c[0].rinfo = rinfo; radeon_create_i2c_busses()
102 rinfo->i2c[0].ddc_reg = GPIO_MONID; radeon_create_i2c_busses()
104 rinfo->i2c[0].adapter.class = I2C_CLASS_HWMON; radeon_create_i2c_busses()
106 radeon_setup_i2c_bus(&rinfo->i2c[0], "monid"); radeon_create_i2c_busses()
108 rinfo->i2c[1].rinfo = rinfo; radeon_create_i2c_busses()
109 rinfo->i2c[1].ddc_reg = GPIO_DVI_DDC; radeon_create_i2c_busses()
110 radeon_setup_i2c_bus(&rinfo->i2c[1], "dvi"); radeon_create_i2c_busses()
112 rinfo->i2c[2].rinfo = rinfo; radeon_create_i2c_busses()
113 rinfo->i2c[2].ddc_reg = GPIO_VGA_DDC; radeon_create_i2c_busses()
114 radeon_setup_i2c_bus(&rinfo->i2c[2], "vga"); radeon_create_i2c_busses()
116 rinfo->i2c[3].rinfo = rinfo; radeon_create_i2c_busses()
117 rinfo->i2c[3].ddc_reg = GPIO_CRT2_DDC; radeon_create_i2c_busses()
118 radeon_setup_i2c_bus(&rinfo->i2c[3], "crt2"); radeon_create_i2c_busses()
123 if (rinfo->i2c[0].rinfo) radeon_delete_i2c_busses()
124 i2c_del_adapter(&rinfo->i2c[0].adapter); radeon_delete_i2c_busses()
125 rinfo->i2c[0].rinfo = NULL; radeon_delete_i2c_busses()
127 if (rinfo->i2c[1].rinfo) radeon_delete_i2c_busses()
128 i2c_del_adapter(&rinfo->i2c[1].adapter); radeon_delete_i2c_busses()
129 rinfo->i2c[1].rinfo = NULL; radeon_delete_i2c_busses()
131 if (rinfo->i2c[2].rinfo) radeon_delete_i2c_busses()
132 i2c_del_adapter(&rinfo->i2c[2].adapter); radeon_delete_i2c_busses()
133 rinfo->i2c[2].rinfo = NULL; radeon_delete_i2c_busses()
135 if (rinfo->i2c[3].rinfo) radeon_delete_i2c_busses()
136 i2c_del_adapter(&rinfo->i2c[3].adapter); radeon_delete_i2c_busses()
137 rinfo->i2c[3].rinfo = NULL; radeon_delete_i2c_busses()
145 edid = fb_ddc_read(&rinfo->i2c[conn-1].adapter); radeon_probe_i2c_connector()
/linux-4.4.14/sound/soc/codecs/
H A Dcs42xx8-i2c.c13 #include <linux/i2c.h>
20 static int cs42xx8_i2c_probe(struct i2c_client *i2c, cs42xx8_i2c_probe() argument
23 int ret = cs42xx8_probe(&i2c->dev, cs42xx8_i2c_probe()
24 devm_regmap_init_i2c(i2c, &cs42xx8_regmap_config)); cs42xx8_i2c_probe()
28 pm_runtime_enable(&i2c->dev); cs42xx8_i2c_probe()
29 pm_request_idle(&i2c->dev); cs42xx8_i2c_probe()
34 static int cs42xx8_i2c_remove(struct i2c_client *i2c) cs42xx8_i2c_remove() argument
36 snd_soc_unregister_codec(&i2c->dev); cs42xx8_i2c_remove()
37 pm_runtime_disable(&i2c->dev); cs42xx8_i2c_remove()
47 MODULE_DEVICE_TABLE(i2c, cs42xx8_i2c_id);
H A Dwm2000.c32 #include <linux/i2c.h>
64 struct i2c_client *i2c; member in struct:wm2000_priv
84 static int wm2000_write(struct i2c_client *i2c, unsigned int reg, wm2000_write() argument
87 struct wm2000_priv *wm2000 = i2c_get_clientdata(i2c); wm2000_write()
91 static unsigned int wm2000_read(struct i2c_client *i2c, unsigned int r) wm2000_read() argument
93 struct wm2000_priv *wm2000 = i2c_get_clientdata(i2c); wm2000_read()
106 struct i2c_client *i2c = wm2000->i2c; wm2000_reset() local
108 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_ENG_CLR); wm2000_reset()
109 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_RAM_CLR); wm2000_reset()
110 wm2000_write(i2c, WM2000_REG_ID1, 0); wm2000_reset()
115 static int wm2000_poll_bit(struct i2c_client *i2c, wm2000_poll_bit() argument
121 val = wm2000_read(i2c, reg); wm2000_poll_bit()
125 val = wm2000_read(i2c, reg); wm2000_poll_bit()
134 static int wm2000_power_up(struct i2c_client *i2c, int analogue) wm2000_power_up() argument
136 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); wm2000_power_up()
143 dev_dbg(&i2c->dev, "Beginning power up\n"); wm2000_power_up()
147 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); wm2000_power_up()
153 dev_dbg(&i2c->dev, "Disabling MCLK divider\n"); wm2000_power_up()
154 wm2000_write(i2c, WM2000_REG_SYS_CTL2, wm2000_power_up()
157 dev_dbg(&i2c->dev, "Enabling MCLK divider\n"); wm2000_power_up()
158 wm2000_write(i2c, WM2000_REG_SYS_CTL2, wm2000_power_up()
162 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_ENG_CLR); wm2000_power_up()
163 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_ENG_SET); wm2000_power_up()
166 if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, wm2000_power_up()
168 dev_err(&i2c->dev, "ANC engine failed to reset\n"); wm2000_power_up()
173 if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, wm2000_power_up()
175 dev_err(&i2c->dev, "ANC engine failed to initialise\n"); wm2000_power_up()
180 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_RAM_SET); wm2000_power_up()
184 dev_dbg(&i2c->dev, "Downloading %d bytes\n", wm2000_power_up()
187 ret = i2c_master_send(i2c, wm2000->anc_download, wm2000_power_up()
190 dev_err(&i2c->dev, "i2c_transfer() failed: %d\n", ret); wm2000_power_up()
195 dev_err(&i2c->dev, "i2c_transfer() failed, %d != %d\n", wm2000_power_up()
201 dev_dbg(&i2c->dev, "Download complete\n"); wm2000_power_up()
204 wm2000_write(i2c, WM2000_REG_ANA_VMID_PU_TIME, 248 / 4); wm2000_power_up()
206 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_power_up()
211 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_power_up()
216 ret = wm2000_read(i2c, WM2000_REG_SPEECH_CLARITY); wm2000_power_up()
221 wm2000_write(i2c, WM2000_REG_SPEECH_CLARITY, ret); wm2000_power_up()
223 wm2000_write(i2c, WM2000_REG_SYS_START0, 0x33); wm2000_power_up()
224 wm2000_write(i2c, WM2000_REG_SYS_START1, 0x02); wm2000_power_up()
226 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); wm2000_power_up()
228 if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, wm2000_power_up()
230 dev_err(&i2c->dev, "Timed out waiting for device\n"); wm2000_power_up()
235 dev_dbg(&i2c->dev, "ANC active\n"); wm2000_power_up()
237 dev_dbg(&i2c->dev, "Analogue active\n"); wm2000_power_up()
243 static int wm2000_power_down(struct i2c_client *i2c, int analogue) wm2000_power_down() argument
245 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); wm2000_power_down()
248 wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4); wm2000_power_down()
249 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_power_down()
253 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_power_down()
257 if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, wm2000_power_down()
259 dev_err(&i2c->dev, "Timeout waiting for ANC power down\n"); wm2000_power_down()
263 if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, wm2000_power_down()
265 dev_err(&i2c->dev, "Timeout waiting for ANC engine idle\n"); wm2000_power_down()
271 dev_dbg(&i2c->dev, "powered off\n"); wm2000_power_down()
277 static int wm2000_enter_bypass(struct i2c_client *i2c, int analogue) wm2000_enter_bypass() argument
279 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); wm2000_enter_bypass()
285 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_enter_bypass()
290 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_enter_bypass()
295 if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, wm2000_enter_bypass()
297 dev_err(&i2c->dev, "Timeout waiting for ANC disable\n"); wm2000_enter_bypass()
301 if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, wm2000_enter_bypass()
303 dev_err(&i2c->dev, "Timeout waiting for ANC engine idle\n"); wm2000_enter_bypass()
307 wm2000_write(i2c, WM2000_REG_SYS_CTL1, WM2000_SYS_STBY); wm2000_enter_bypass()
308 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_RAM_CLR); wm2000_enter_bypass()
311 dev_dbg(&i2c->dev, "bypass enabled\n"); wm2000_enter_bypass()
316 static int wm2000_exit_bypass(struct i2c_client *i2c, int analogue) wm2000_exit_bypass() argument
318 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); wm2000_exit_bypass()
323 wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); wm2000_exit_bypass()
326 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_exit_bypass()
331 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_exit_bypass()
336 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_RAM_SET); wm2000_exit_bypass()
337 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); wm2000_exit_bypass()
339 if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, wm2000_exit_bypass()
341 dev_err(&i2c->dev, "Timed out waiting for MOUSE\n"); wm2000_exit_bypass()
346 dev_dbg(&i2c->dev, "MOUSE active\n"); wm2000_exit_bypass()
351 static int wm2000_enter_standby(struct i2c_client *i2c, int analogue) wm2000_enter_standby() argument
353 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); wm2000_enter_standby()
359 wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4); wm2000_enter_standby()
361 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_enter_standby()
366 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_enter_standby()
371 if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, wm2000_enter_standby()
373 dev_err(&i2c->dev, wm2000_enter_standby()
378 if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, WM2000_ANC_ENG_IDLE)) { wm2000_enter_standby()
379 dev_err(&i2c->dev, wm2000_enter_standby()
384 wm2000_write(i2c, WM2000_REG_SYS_CTL1, WM2000_SYS_STBY); wm2000_enter_standby()
385 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_RAM_CLR); wm2000_enter_standby()
388 dev_dbg(&i2c->dev, "standby\n"); wm2000_enter_standby()
390 dev_dbg(&i2c->dev, "Analogue disabled\n"); wm2000_enter_standby()
395 static int wm2000_exit_standby(struct i2c_client *i2c, int analogue) wm2000_exit_standby() argument
397 struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); wm2000_exit_standby()
402 wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); wm2000_exit_standby()
405 wm2000_write(i2c, WM2000_REG_ANA_VMID_PU_TIME, 248 / 4); wm2000_exit_standby()
407 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_exit_standby()
412 wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, wm2000_exit_standby()
417 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_RAM_SET); wm2000_exit_standby()
418 wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); wm2000_exit_standby()
420 if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, wm2000_exit_standby()
422 dev_err(&i2c->dev, "Timed out waiting for MOUSE\n"); wm2000_exit_standby()
427 dev_dbg(&i2c->dev, "MOUSE active\n"); wm2000_exit_standby()
429 dev_dbg(&i2c->dev, "Analogue enabled\n"); wm2000_exit_standby()
434 typedef int (*wm2000_mode_fn)(struct i2c_client *i2c, int analogue);
546 struct i2c_client *i2c = wm2000->i2c; wm2000_anc_transition() local
558 dev_err(&i2c->dev, "No transition for %d->%d\n", wm2000_anc_transition()
567 dev_err(&i2c->dev, "Failed to enable MCLK: %d\n", ret); wm2000_anc_transition()
575 ret = anc_transitions[i].step[j](i2c, wm2000_anc_transition()
589 struct i2c_client *i2c = wm2000->i2c; wm2000_anc_set_mode() local
600 dev_dbg(&i2c->dev, "Set mode %d (enabled %d, mute %d, active %d)\n", wm2000_anc_set_mode()
816 static int wm2000_i2c_probe(struct i2c_client *i2c, wm2000_i2c_probe() argument
827 wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv), wm2000_i2c_probe()
834 dev_set_drvdata(&i2c->dev, wm2000); wm2000_i2c_probe()
836 wm2000->regmap = devm_regmap_init_i2c(i2c, &wm2000_regmap); wm2000_i2c_probe()
839 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", wm2000_i2c_probe()
847 ret = devm_regulator_bulk_get(&i2c->dev, WM2000_NUM_SUPPLIES, wm2000_i2c_probe()
850 dev_err(&i2c->dev, "Failed to get supplies: %d\n", ret); wm2000_i2c_probe()
856 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); wm2000_i2c_probe()
861 reg = wm2000_read(i2c, WM2000_REG_ID1); wm2000_i2c_probe()
863 reg = wm2000_read(i2c, WM2000_REG_ID2); wm2000_i2c_probe()
867 dev_err(&i2c->dev, "Device is not a WM2000 - ID %x\n", id); wm2000_i2c_probe()
872 reg = wm2000_read(i2c, WM2000_REG_REVISON); wm2000_i2c_probe()
873 dev_info(&i2c->dev, "revision %c\n", reg + 'A'); wm2000_i2c_probe()
875 wm2000->mclk = devm_clk_get(&i2c->dev, "MCLK"); wm2000_i2c_probe()
878 dev_err(&i2c->dev, "Failed to get MCLK: %d\n", ret); wm2000_i2c_probe()
883 pdata = dev_get_platdata(&i2c->dev); wm2000_i2c_probe()
891 ret = request_firmware(&fw, filename, &i2c->dev); wm2000_i2c_probe()
893 dev_err(&i2c->dev, "Failed to acquire ANC data: %d\n", ret); wm2000_i2c_probe()
899 wm2000->anc_download = devm_kzalloc(&i2c->dev, wm2000_i2c_probe()
903 dev_err(&i2c->dev, "Out of memory\n"); wm2000_i2c_probe()
915 wm2000->i2c = i2c; wm2000_i2c_probe()
919 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0); wm2000_i2c_probe()
929 static int wm2000_i2c_remove(struct i2c_client *i2c) wm2000_i2c_remove() argument
931 snd_soc_unregister_codec(&i2c->dev); wm2000_i2c_remove()
940 MODULE_DEVICE_TABLE(i2c, wm2000_i2c_id);
H A Dwm8804-i2c.c2 * wm8804-i2c.c -- WM8804 S/PDIF transceiver driver - I2C
15 #include <linux/i2c.h>
19 static int wm8804_i2c_probe(struct i2c_client *i2c, wm8804_i2c_probe() argument
24 regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config); wm8804_i2c_probe()
28 return wm8804_probe(&i2c->dev, regmap); wm8804_i2c_probe()
31 static int wm8804_i2c_remove(struct i2c_client *i2c) wm8804_i2c_remove() argument
33 wm8804_remove(&i2c->dev); wm8804_i2c_remove()
41 MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
H A Des8328-i2c.c2 * es8328-i2c.c -- ES8328 ALSA SoC I2C Audio driver
14 #include <linux/i2c.h>
25 MODULE_DEVICE_TABLE(i2c, es8328_id);
33 static int es8328_i2c_probe(struct i2c_client *i2c, es8328_i2c_probe() argument
36 return es8328_probe(&i2c->dev, es8328_i2c_probe()
37 devm_regmap_init_i2c(i2c, &es8328_regmap_config)); es8328_i2c_probe()
40 static int es8328_i2c_remove(struct i2c_client *i2c) es8328_i2c_remove() argument
42 snd_soc_unregister_codec(&i2c->dev); es8328_i2c_remove()
H A Dcs42l51-i2c.c14 #include <linux/i2c.h>
24 MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id);
26 static int cs42l51_i2c_probe(struct i2c_client *i2c, cs42l51_i2c_probe() argument
35 return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config)); cs42l51_i2c_probe()
38 static int cs42l51_i2c_remove(struct i2c_client *i2c) cs42l51_i2c_remove() argument
40 snd_soc_unregister_codec(&i2c->dev); cs42l51_i2c_remove()
H A Dwm1250-ev1.c16 #include <linux/i2c.h>
154 static int wm1250_ev1_pdata(struct i2c_client *i2c) wm1250_ev1_pdata() argument
156 struct wm1250_ev1_pdata *pdata = dev_get_platdata(&i2c->dev); wm1250_ev1_pdata()
163 wm1250 = devm_kzalloc(&i2c->dev, sizeof(*wm1250), GFP_KERNEL); wm1250_ev1_pdata()
179 dev_err(&i2c->dev, "Failed to get GPIOs: %d\n", ret); wm1250_ev1_pdata()
183 dev_set_drvdata(&i2c->dev, wm1250); wm1250_ev1_pdata()
191 static void wm1250_ev1_free(struct i2c_client *i2c) wm1250_ev1_free() argument
193 struct wm1250_priv *wm1250 = dev_get_drvdata(&i2c->dev); wm1250_ev1_free()
199 static int wm1250_ev1_probe(struct i2c_client *i2c, wm1250_ev1_probe() argument
204 dev_set_drvdata(&i2c->dev, NULL); wm1250_ev1_probe()
206 board = i2c_smbus_read_byte_data(i2c, 0); wm1250_ev1_probe()
208 dev_err(&i2c->dev, "Failed to read ID: %d\n", board); wm1250_ev1_probe()
216 dev_err(&i2c->dev, "Unknown board ID %d\n", id); wm1250_ev1_probe()
220 dev_info(&i2c->dev, "revision %d\n", rev + 1); wm1250_ev1_probe()
222 ret = wm1250_ev1_pdata(i2c); wm1250_ev1_probe()
226 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm1250_ev1, wm1250_ev1_probe()
229 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); wm1250_ev1_probe()
230 wm1250_ev1_free(i2c); wm1250_ev1_probe()
237 static int wm1250_ev1_remove(struct i2c_client *i2c) wm1250_ev1_remove() argument
239 snd_soc_unregister_codec(&i2c->dev); wm1250_ev1_remove()
240 wm1250_ev1_free(i2c); wm1250_ev1_remove()
249 MODULE_DEVICE_TABLE(i2c, wm1250_ev1_i2c_id);
H A Dtlv320aic23-i2c.c14 #include <linux/i2c.h>
22 static int tlv320aic23_i2c_probe(struct i2c_client *i2c, tlv320aic23_i2c_probe() argument
27 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) tlv320aic23_i2c_probe()
30 regmap = devm_regmap_init_i2c(i2c, &tlv320aic23_regmap); tlv320aic23_i2c_probe()
31 return tlv320aic23_probe(&i2c->dev, regmap); tlv320aic23_i2c_probe()
34 static int tlv320aic23_i2c_remove(struct i2c_client *i2c) tlv320aic23_i2c_remove() argument
36 snd_soc_unregister_codec(&i2c->dev); tlv320aic23_i2c_remove()
45 MODULE_DEVICE_TABLE(i2c, tlv320aic23_id);
H A Dpcm512x-i2c.c19 #include <linux/i2c.h>
23 static int pcm512x_i2c_probe(struct i2c_client *i2c, pcm512x_i2c_probe() argument
33 regmap = devm_regmap_init_i2c(i2c, &config); pcm512x_i2c_probe()
37 return pcm512x_probe(&i2c->dev, regmap); pcm512x_i2c_probe()
40 static int pcm512x_i2c_remove(struct i2c_client *i2c) pcm512x_i2c_remove() argument
42 pcm512x_remove(&i2c->dev); pcm512x_i2c_remove()
53 MODULE_DEVICE_TABLE(i2c, pcm512x_i2c_id);
H A Dad193x-i2c.c10 #include <linux/i2c.h>
22 MODULE_DEVICE_TABLE(i2c, ad193x_id);
H A Dadav803.c10 #include <linux/i2c.h>
21 MODULE_DEVICE_TABLE(i2c, adav803_id);
H A DMakefile7 snd-soc-ad193x-i2c-objs := ad193x-i2c.o
14 snd-soc-adau1761-i2c-objs := adau1761-i2c.o
17 snd-soc-adau1781-i2c-objs := adau1781-i2c.o
21 snd-soc-adau1977-i2c-objs := adau1977-i2c.o
38 snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o
45 snd-soc-cs4271-i2c-objs := cs4271-i2c.o
48 snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
59 snd-soc-es8328-i2c-objs := es8328-i2c.o
82 snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o
99 snd-soc-sigmadsp-i2c-objs := sigmadsp-i2c.o
109 snd-soc-ssm2602-i2c-objs := ssm2602-i2c.o
120 snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
158 snd-soc-wm8804-i2c-objs := wm8804-i2c.o
200 obj-$(CONFIG_SND_SOC_AD193X_I2C) += snd-soc-ad193x-i2c.o
207 obj-$(CONFIG_SND_SOC_ADAU1761_I2C) += snd-soc-adau1761-i2c.o
210 obj-$(CONFIG_SND_SOC_ADAU1781_I2C) += snd-soc-adau1781-i2c.o
214 obj-$(CONFIG_SND_SOC_ADAU1977_I2C) += snd-soc-adau1977-i2c.o
233 obj-$(CONFIG_SND_SOC_CS42L51_I2C) += snd-soc-cs42l51-i2c.o
240 obj-$(CONFIG_SND_SOC_CS4271_I2C) += snd-soc-cs4271-i2c.o
243 obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
254 obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
277 obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o
292 obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o
300 obj-$(CONFIG_SND_SOC_SSM2602_I2C) += snd-soc-ssm2602-i2c.o
312 obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
349 obj-$(CONFIG_SND_SOC_WM8804_I2C) += snd-soc-wm8804-i2c.o
/linux-4.4.14/drivers/media/pci/cx23885/
H A Dnetup-init.c25 static void i2c_av_write(struct i2c_adapter *i2c, u16 reg, u8 val) i2c_av_write() argument
40 ret = i2c_transfer(i2c, &msg, 1); i2c_av_write()
43 printk(KERN_ERR "%s: i2c write error!\n", __func__); i2c_av_write()
46 static void i2c_av_write4(struct i2c_adapter *i2c, u16 reg, u32 val) i2c_av_write4() argument
64 ret = i2c_transfer(i2c, &msg, 1); i2c_av_write4()
67 printk(KERN_ERR "%s: i2c write error!\n", __func__); i2c_av_write4()
70 static u8 i2c_av_read(struct i2c_adapter *i2c, u16 reg) i2c_av_read() argument
84 ret = i2c_transfer(i2c, &msg, 1); i2c_av_read()
87 printk(KERN_ERR "%s: i2c write error!\n", __func__); i2c_av_read()
92 ret = i2c_transfer(i2c, &msg, 1); i2c_av_read()
95 printk(KERN_ERR "%s: i2c read error!\n", __func__); i2c_av_read()
100 static void i2c_av_and_or(struct i2c_adapter *i2c, u16 reg, unsigned and_mask, i2c_av_and_or() argument
103 i2c_av_write(i2c, reg, (i2c_av_read(i2c, reg) & and_mask) | or_value); i2c_av_and_or()
109 struct i2c_adapter *i2c = &i2c_bus->i2c_adap; netup_initialize() local
112 i2c_av_and_or(i2c, 0x803, ~0x10, 0x00); netup_initialize()
115 i2c_av_write4(i2c, 0x114, 0xea0eb3); netup_initialize()
118 i2c_av_write4(i2c, 0x110, 0x090319); netup_initialize()
121 i2c_av_and_or(i2c, 0x803, ~0x10, 0x10); netup_initialize()
H A DMakefile2 cx23885-core.o cx23885-i2c.o cx23885-dvb.o cx23885-417.o \
10 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/
H A Dbase.c33 #include <subdev/bios/i2c.h>
36 nvkm_i2c_pad_find(struct nvkm_i2c *i2c, int id) nvkm_i2c_pad_find() argument
40 list_for_each_entry(pad, &i2c->pad, head) { nvkm_i2c_pad_find()
49 nvkm_i2c_bus_find(struct nvkm_i2c *i2c, int id) nvkm_i2c_bus_find() argument
51 struct nvkm_bios *bios = i2c->subdev.device->bios; nvkm_i2c_bus_find()
56 u16 i2c = dcb_i2c_table(bios, &ver, &hdr, &cnt, &len); nvkm_i2c_bus_find() local
57 if (i2c && ver >= 0x30) { nvkm_i2c_bus_find()
58 u8 auxidx = nvbios_rd08(bios, i2c + 4); nvkm_i2c_bus_find()
68 list_for_each_entry(bus, &i2c->bus, head) { nvkm_i2c_bus_find()
77 nvkm_i2c_aux_find(struct nvkm_i2c *i2c, int id) nvkm_i2c_aux_find() argument
81 list_for_each_entry(aux, &i2c->aux, head) { nvkm_i2c_aux_find()
92 struct nvkm_i2c *i2c = container_of(event, typeof(*i2c), event); nvkm_i2c_intr_fini() local
93 struct nvkm_i2c_aux *aux = nvkm_i2c_aux_find(i2c, id); nvkm_i2c_intr_fini()
95 i2c->func->aux_mask(i2c, type, aux->intr, 0); nvkm_i2c_intr_fini()
101 struct nvkm_i2c *i2c = container_of(event, typeof(*i2c), event); nvkm_i2c_intr_init() local
102 struct nvkm_i2c_aux *aux = nvkm_i2c_aux_find(i2c, id); nvkm_i2c_intr_init()
104 i2c->func->aux_mask(i2c, type, aux->intr, aux->intr); nvkm_i2c_intr_init()
131 struct nvkm_i2c *i2c = nvkm_i2c(subdev); nvkm_i2c_intr() local
135 if (!i2c->func->aux_stat) nvkm_i2c_intr()
138 i2c->func->aux_stat(i2c, &hi, &lo, &rq, &tx); nvkm_i2c_intr()
142 list_for_each_entry(aux, &i2c->aux, head) { nvkm_i2c_intr()
152 nvkm_event_send(&i2c->event, rep.mask, aux->id, nvkm_i2c_intr()
161 struct nvkm_i2c *i2c = nvkm_i2c(subdev); nvkm_i2c_fini() local
165 if ((mask = (1 << i2c->func->aux) - 1), i2c->func->aux_stat) { nvkm_i2c_fini()
166 i2c->func->aux_mask(i2c, NVKM_I2C_ANY, mask, 0); nvkm_i2c_fini()
167 i2c->func->aux_stat(i2c, &mask, &mask, &mask, &mask); nvkm_i2c_fini()
170 list_for_each_entry(pad, &i2c->pad, head) { nvkm_i2c_fini()
180 struct nvkm_i2c *i2c = nvkm_i2c(subdev); nvkm_i2c_init() local
184 list_for_each_entry(pad, &i2c->pad, head) { nvkm_i2c_init()
188 list_for_each_entry(bus, &i2c->bus, head) { nvkm_i2c_init()
198 struct nvkm_i2c *i2c = nvkm_i2c(subdev); nvkm_i2c_dtor() local
200 nvkm_event_fini(&i2c->event); nvkm_i2c_dtor()
202 while (!list_empty(&i2c->aux)) { nvkm_i2c_dtor()
204 list_first_entry(&i2c->aux, typeof(*aux), head); nvkm_i2c_dtor()
208 while (!list_empty(&i2c->bus)) { nvkm_i2c_dtor()
210 list_first_entry(&i2c->bus, typeof(*bus), head); nvkm_i2c_dtor()
214 while (!list_empty(&i2c->pad)) { nvkm_i2c_dtor()
216 list_first_entry(&i2c->pad, typeof(*pad), head); nvkm_i2c_dtor()
220 return i2c; nvkm_i2c_dtor()
248 struct nvkm_i2c *i2c; nvkm_i2c_new_() local
254 if (!(i2c = *pi2c = kzalloc(sizeof(*i2c), GFP_KERNEL))) nvkm_i2c_new_()
257 nvkm_subdev_ctor(&nvkm_i2c, device, index, 0, &i2c->subdev); nvkm_i2c_new_()
258 i2c->func = func; nvkm_i2c_new_()
259 INIT_LIST_HEAD(&i2c->pad); nvkm_i2c_new_()
260 INIT_LIST_HEAD(&i2c->bus); nvkm_i2c_new_()
261 INIT_LIST_HEAD(&i2c->aux); nvkm_i2c_new_()
269 nvkm_debug(&i2c->subdev, "ccb %02x: type %02x drive %02x " nvkm_i2c_new_()
275 if (!(pad = nvkm_i2c_pad_find(i2c, id))) nvkm_i2c_new_()
276 ret = func->pad_s_new(i2c, id, &pad); nvkm_i2c_new_()
280 ret = func->pad_x_new(i2c, NVKM_I2C_PAD_CCB(i), &pad); nvkm_i2c_new_()
284 nvkm_error(&i2c->subdev, "ccb %02x pad, %d\n", i, ret); nvkm_i2c_new_()
304 nvkm_error(&i2c->subdev, "ccb %02x bus, %d\n", i, ret); nvkm_i2c_new_()
319 nvkm_error(&i2c->subdev, "ccb %02x aux, %d\n", i, ret); nvkm_i2c_new_()
324 nvkm_warn(&i2c->subdev, "ccb %02x was ignored\n", i); nvkm_i2c_new_()
335 /* internal outputs handled by native i2c busses (above) */ nvkm_i2c_new_()
339 /* we need an i2c bus to talk to the external encoder */ nvkm_i2c_new_()
340 bus = nvkm_i2c_bus_find(i2c, dcbE.i2c_index); nvkm_i2c_new_()
342 nvkm_debug(&i2c->subdev, "dcb %02x no bus\n", i); nvkm_i2c_new_()
354 nvkm_debug(&i2c->subdev, "dcb %02x drv %02x unknown\n", nvkm_i2c_new_()
360 pad = nvkm_i2c_pad_find(i2c, NVKM_I2C_PAD_EXT(dcbE.extdev)); nvkm_i2c_new_()
365 nvkm_error(&i2c->subdev, "dcb %02x pad, %d\n", nvkm_i2c_new_()
372 /* create any i2c bus / aux channel required by the output */ nvkm_i2c_new_()
378 nvkm_error(&i2c->subdev, "dcb %02x aux, %d\n", nvkm_i2c_new_()
388 nvkm_error(&i2c->subdev, "dcb %02x bus, %d\n", nvkm_i2c_new_()
395 return nvkm_event_init(&nvkm_i2c_intr_func, 4, i, &i2c->event); nvkm_i2c_new_()
H A Dbus.c30 * i2c-algo-bit
35 struct nvkm_i2c_bus *bus = container_of(adap, typeof(*bus), i2c); nvkm_i2c_bus_pre_xfer()
42 struct nvkm_i2c_bus *bus = container_of(adap, typeof(*bus), i2c); nvkm_i2c_bus_post_xfer()
75 * !i2c-algo-bit (off-chip i2c bus / hw i2c / internal bit-banging algo)
80 struct nvkm_i2c_bus *bus = container_of(adap, typeof(*bus), i2c); nvkm_i2c_bus_xfer()
149 if ((bus->i2c.algo == &i2c_bit_algo) && (info[i].udelay != 0)) { nvkm_i2c_bus_probe()
150 struct i2c_algo_bit_data *algo = bus->i2c.algo_data; nvkm_i2c_bus_probe()
157 if (nvkm_probe_i2c(&bus->i2c, info[i].dev.addr) && nvkm_i2c_bus_probe()
165 struct i2c_algo_bit_data *algo = bus->i2c.algo_data; nvkm_i2c_bus_probe()
181 i2c_del_adapter(&bus->i2c); nvkm_i2c_bus_del()
182 kfree(bus->i2c.algo_data); nvkm_i2c_bus_del()
193 struct nvkm_device *device = pad->i2c->subdev.device; nvkm_i2c_bus_ctor()
206 list_add_tail(&bus->head, &pad->i2c->bus); nvkm_i2c_bus_ctor()
209 snprintf(bus->i2c.name, sizeof(bus->i2c.name), "nvkm-%s-bus-%04x", nvkm_i2c_bus_ctor()
211 bus->i2c.owner = THIS_MODULE; nvkm_i2c_bus_ctor()
212 bus->i2c.dev.parent = device->dev; nvkm_i2c_bus_ctor()
227 bus->i2c.algo_data = bit; nvkm_i2c_bus_ctor()
228 ret = i2c_bit_add_bus(&bus->i2c); nvkm_i2c_bus_ctor()
230 bus->i2c.algo = &nvkm_i2c_bus_algo; nvkm_i2c_bus_ctor()
231 ret = i2c_add_adapter(&bus->i2c); nvkm_i2c_bus_ctor()
H A Dpadgf119.c36 gf119_i2c_pad_s_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad) gf119_i2c_pad_s_new() argument
38 return nvkm_i2c_pad_new_(&gf119_i2c_pad_s_func, i2c, id, ppad); gf119_i2c_pad_s_new()
48 gf119_i2c_pad_x_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad) gf119_i2c_pad_x_new() argument
50 return nvkm_i2c_pad_new_(&gf119_i2c_pad_x_func, i2c, id, ppad); gf119_i2c_pad_x_new()
H A Dpad.c30 (mode == NVKM_I2C_PAD_I2C) ? "i2c" : "off"); nvkm_i2c_pad_mode_locked()
96 nvkm_i2c_pad_ctor(const struct nvkm_i2c_pad_func *func, struct nvkm_i2c *i2c, nvkm_i2c_pad_ctor() argument
100 pad->i2c = i2c; nvkm_i2c_pad_ctor()
104 list_add_tail(&pad->head, &i2c->pad); nvkm_i2c_pad_ctor()
109 nvkm_i2c_pad_new_(const struct nvkm_i2c_pad_func *func, struct nvkm_i2c *i2c, nvkm_i2c_pad_new_() argument
114 nvkm_i2c_pad_ctor(func, i2c, id, *ppad); nvkm_i2c_pad_new_()
H A Daux.c30 struct nvkm_i2c_aux *aux = container_of(adap, typeof(*aux), i2c); nvkm_i2c_aux_i2c_xfer()
138 i2c_del_adapter(&aux->i2c); nvkm_i2c_aux_del()
149 struct nvkm_device *device = pad->i2c->subdev.device; nvkm_i2c_aux_ctor()
155 list_add_tail(&aux->head, &pad->i2c->aux); nvkm_i2c_aux_ctor()
158 snprintf(aux->i2c.name, sizeof(aux->i2c.name), "nvkm-%s-aux-%04x", nvkm_i2c_aux_ctor()
160 aux->i2c.owner = THIS_MODULE; nvkm_i2c_aux_ctor()
161 aux->i2c.dev.parent = device->dev; nvkm_i2c_aux_ctor()
162 aux->i2c.algo = &nvkm_i2c_aux_i2c_algo; nvkm_i2c_aux_ctor()
163 return i2c_add_adapter(&aux->i2c); nvkm_i2c_aux_ctor()
H A Dpadg94.c31 struct nvkm_subdev *subdev = &pad->i2c->subdev; g94_i2c_pad_mode()
61 g94_i2c_pad_s_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad) g94_i2c_pad_s_new() argument
63 return nvkm_i2c_pad_new_(&g94_i2c_pad_s_func, i2c, id, ppad); g94_i2c_pad_s_new()
73 g94_i2c_pad_x_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad) g94_i2c_pad_x_new() argument
75 return nvkm_i2c_pad_new_(&g94_i2c_pad_x_func, i2c, id, ppad); g94_i2c_pad_x_new()
H A Dpadgm204.c31 struct nvkm_subdev *subdev = &pad->i2c->subdev; gm204_i2c_pad_mode()
61 gm204_i2c_pad_s_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad) gm204_i2c_pad_s_new() argument
63 return nvkm_i2c_pad_new_(&gm204_i2c_pad_s_func, i2c, id, ppad); gm204_i2c_pad_s_new()
73 gm204_i2c_pad_x_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad) gm204_i2c_pad_x_new() argument
75 return nvkm_i2c_pad_new_(&gm204_i2c_pad_x_func, i2c, id, ppad); gm204_i2c_pad_x_new()
/linux-4.4.14/drivers/video/fbdev/matrox/
H A Dmatroxfb_maven.h5 #include <linux/i2c.h>
6 #include <linux/i2c-algo-bit.h>
H A Di2c-matroxfb.c15 #include <linux/i2c.h>
17 #include <linux/i2c-algo-bit.h>
177 printk(KERN_INFO "i2c-matroxfb: VGA->TV plug detected, DDC unavailable.\n"); i2c_matroxfb_probe()
179 printk(KERN_INFO "i2c-matroxfb: Could not register secondary output i2c bus. Continuing anyway.\n"); i2c_matroxfb_probe()
184 printk(KERN_INFO "i2c-matroxfb: Could not register Maven i2c bus. Continuing anyway.\n"); i2c_matroxfb_probe()
200 printk(KERN_ERR "i2c-matroxfb: Could not register primary adapter DDC bus.\n"); i2c_matroxfb_probe()
215 .name = "i2c-matroxfb",
222 printk(KERN_ERR "i2c-matroxfb: failed to register driver\n"); i2c_matroxfb_init()
/linux-4.4.14/drivers/media/i2c/cx25840/
H A DMakefile6 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/nfc/s3fwrn5/
H A DMakefile6 s3fwrn5_i2c-objs = i2c.o
/linux-4.4.14/drivers/gpu/drm/amd/amdgpu/
H A Damdgpu_i2c.c38 /* bit banging i2c */ amdgpu_i2c_pre_xfer()
41 struct amdgpu_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); amdgpu_i2c_pre_xfer() local
42 struct amdgpu_device *adev = i2c->dev->dev_private; amdgpu_i2c_pre_xfer()
43 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; amdgpu_i2c_pre_xfer()
46 mutex_lock(&i2c->mutex); amdgpu_i2c_pre_xfer()
83 struct amdgpu_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); amdgpu_i2c_post_xfer() local
84 struct amdgpu_device *adev = i2c->dev->dev_private; amdgpu_i2c_post_xfer()
85 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; amdgpu_i2c_post_xfer()
97 mutex_unlock(&i2c->mutex); amdgpu_i2c_post_xfer()
102 struct amdgpu_i2c_chan *i2c = i2c_priv; amdgpu_i2c_get_clock() local
103 struct amdgpu_device *adev = i2c->dev->dev_private; amdgpu_i2c_get_clock()
104 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; amdgpu_i2c_get_clock()
117 struct amdgpu_i2c_chan *i2c = i2c_priv; amdgpu_i2c_get_data() local
118 struct amdgpu_device *adev = i2c->dev->dev_private; amdgpu_i2c_get_data()
119 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; amdgpu_i2c_get_data()
131 struct amdgpu_i2c_chan *i2c = i2c_priv; amdgpu_i2c_set_clock() local
132 struct amdgpu_device *adev = i2c->dev->dev_private; amdgpu_i2c_set_clock()
133 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; amdgpu_i2c_set_clock()
144 struct amdgpu_i2c_chan *i2c = i2c_priv; amdgpu_i2c_set_data() local
145 struct amdgpu_device *adev = i2c->dev->dev_private; amdgpu_i2c_set_data()
146 struct amdgpu_i2c_bus_rec *rec = &i2c->rec; amdgpu_i2c_set_data()
164 struct amdgpu_i2c_chan *i2c; amdgpu_i2c_create() local
171 i2c = kzalloc(sizeof(struct amdgpu_i2c_chan), GFP_KERNEL); amdgpu_i2c_create()
172 if (i2c == NULL) amdgpu_i2c_create()
175 i2c->rec = *rec; amdgpu_i2c_create()
176 i2c->adapter.owner = THIS_MODULE; amdgpu_i2c_create()
177 i2c->adapter.class = I2C_CLASS_DDC; amdgpu_i2c_create()
178 i2c->adapter.dev.parent = &dev->pdev->dev; amdgpu_i2c_create()
179 i2c->dev = dev; amdgpu_i2c_create()
180 i2c_set_adapdata(&i2c->adapter, i2c); amdgpu_i2c_create()
181 mutex_init(&i2c->mutex); amdgpu_i2c_create()
184 /* hw i2c using atom */ amdgpu_i2c_create()
185 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), amdgpu_i2c_create()
186 "AMDGPU i2c hw bus %s", name); amdgpu_i2c_create()
187 i2c->adapter.algo = &amdgpu_atombios_i2c_algo; amdgpu_i2c_create()
188 ret = i2c_add_adapter(&i2c->adapter); amdgpu_i2c_create()
190 DRM_ERROR("Failed to register hw i2c %s\n", name); amdgpu_i2c_create()
195 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), amdgpu_i2c_create()
196 "AMDGPU i2c bit bus %s", name); amdgpu_i2c_create()
197 i2c->adapter.algo_data = &i2c->bit; amdgpu_i2c_create()
198 i2c->bit.pre_xfer = amdgpu_i2c_pre_xfer; amdgpu_i2c_create()
199 i2c->bit.post_xfer = amdgpu_i2c_post_xfer; amdgpu_i2c_create()
200 i2c->bit.setsda = amdgpu_i2c_set_data; amdgpu_i2c_create()
201 i2c->bit.setscl = amdgpu_i2c_set_clock; amdgpu_i2c_create()
202 i2c->bit.getsda = amdgpu_i2c_get_data; amdgpu_i2c_create()
203 i2c->bit.getscl = amdgpu_i2c_get_clock; amdgpu_i2c_create()
204 i2c->bit.udelay = 10; amdgpu_i2c_create()
205 i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ amdgpu_i2c_create()
206 i2c->bit.data = i2c; amdgpu_i2c_create()
207 ret = i2c_bit_add_bus(&i2c->adapter); amdgpu_i2c_create()
209 DRM_ERROR("Failed to register bit i2c %s\n", name); amdgpu_i2c_create()
214 return i2c; amdgpu_i2c_create()
216 kfree(i2c); amdgpu_i2c_create()
221 void amdgpu_i2c_destroy(struct amdgpu_i2c_chan *i2c) amdgpu_i2c_destroy() argument
223 if (!i2c) amdgpu_i2c_destroy()
225 i2c_del_adapter(&i2c->adapter); amdgpu_i2c_destroy()
226 kfree(i2c); amdgpu_i2c_destroy()
313 DRM_DEBUG("i2c 0x%02x 0x%02x read failed\n", amdgpu_i2c_get_byte()
335 DRM_DEBUG("i2c 0x%02x 0x%02x write failed\n", amdgpu_i2c_put_byte()
/linux-4.4.14/drivers/input/touchscreen/
H A Dtsc2004.c21 #include <linux/i2c.h>
29 struct i2c_client *i2c = to_i2c_client(dev); tsc2004_cmd() local
31 data = i2c_smbus_write_byte(i2c, tx); tsc2004_cmd()
33 dev_err(dev, "%s: failed, command: %x i2c error: %d\n", tsc2004_cmd()
41 static int tsc2004_probe(struct i2c_client *i2c, tsc2004_probe() argument
45 return tsc200x_probe(&i2c->dev, i2c->irq, BUS_I2C, tsc2004_probe()
46 devm_regmap_init_i2c(i2c, &tsc200x_regmap_config), tsc2004_probe()
50 static int tsc2004_remove(struct i2c_client *i2c) tsc2004_remove() argument
52 return tsc200x_remove(&i2c->dev); tsc2004_remove()
59 MODULE_DEVICE_TABLE(i2c, tsc2004_idtable);
H A Dbu21013_ts.c10 #include <linux/i2c.h>
141 * @client: pointer to the i2c client
167 * Read the touch co-ordinates using i2c read block into buffer
259 struct i2c_client *i2c = data->client; bu21013_gpio_irq() local
265 dev_err(&i2c->dev, "bu21013_do_touch_report failed\n"); bu21013_gpio_irq()
288 struct i2c_client *i2c = data->client; bu21013_init_chip() local
290 retval = i2c_smbus_write_byte_data(i2c, BU21013_RESET_REG, bu21013_init_chip()
293 dev_err(&i2c->dev, "BU21013_RESET reg write failed\n"); bu21013_init_chip()
298 retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_0_7_REG, bu21013_init_chip()
301 dev_err(&i2c->dev, "BU21013_SENSOR_0_7 reg write failed\n"); bu21013_init_chip()
305 retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_8_15_REG, bu21013_init_chip()
308 dev_err(&i2c->dev, "BU21013_SENSOR_8_15 reg write failed\n"); bu21013_init_chip()
312 retval = i2c_smbus_write_byte_data(i2c, BU21013_SENSOR_16_23_REG, bu21013_init_chip()
315 dev_err(&i2c->dev, "BU21013_SENSOR_16_23 reg write failed\n"); bu21013_init_chip()
319 retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE1_REG, bu21013_init_chip()
322 dev_err(&i2c->dev, "BU21013_POS_MODE1 reg write failed\n"); bu21013_init_chip()
326 retval = i2c_smbus_write_byte_data(i2c, BU21013_POS_MODE2_REG, bu21013_init_chip()
331 dev_err(&i2c->dev, "BU21013_POS_MODE2 reg write failed\n"); bu21013_init_chip()
336 retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG, bu21013_init_chip()
339 retval = i2c_smbus_write_byte_data(i2c, BU21013_CLK_MODE_REG, bu21013_init_chip()
342 dev_err(&i2c->dev, "BU21013_CLK_MODE reg write failed\n"); bu21013_init_chip()
346 retval = i2c_smbus_write_byte_data(i2c, BU21013_IDLE_REG, bu21013_init_chip()
349 dev_err(&i2c->dev, "BU21013_IDLE reg write failed\n"); bu21013_init_chip()
353 retval = i2c_smbus_write_byte_data(i2c, BU21013_INT_MODE_REG, bu21013_init_chip()
356 dev_err(&i2c->dev, "BU21013_INT_MODE reg write failed\n"); bu21013_init_chip()
360 retval = i2c_smbus_write_byte_data(i2c, BU21013_FILTER_REG, bu21013_init_chip()
364 dev_err(&i2c->dev, "BU21013_FILTER reg write failed\n"); bu21013_init_chip()
368 retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_ON_REG, bu21013_init_chip()
371 dev_err(&i2c->dev, "BU21013_TH_ON reg write failed\n"); bu21013_init_chip()
375 retval = i2c_smbus_write_byte_data(i2c, BU21013_TH_OFF_REG, bu21013_init_chip()
378 dev_err(&i2c->dev, "BU21013_TH_OFF reg write failed\n"); bu21013_init_chip()
382 retval = i2c_smbus_write_byte_data(i2c, BU21013_GAIN_REG, bu21013_init_chip()
385 dev_err(&i2c->dev, "BU21013_GAIN reg write failed\n"); bu21013_init_chip()
389 retval = i2c_smbus_write_byte_data(i2c, BU21013_OFFSET_MODE_REG, bu21013_init_chip()
392 dev_err(&i2c->dev, "BU21013_OFFSET_MODE reg write failed\n"); bu21013_init_chip()
396 retval = i2c_smbus_write_byte_data(i2c, BU21013_XY_EDGE_REG, bu21013_init_chip()
400 dev_err(&i2c->dev, "BU21013_XY_EDGE reg write failed\n"); bu21013_init_chip()
404 retval = i2c_smbus_write_byte_data(i2c, BU21013_DONE_REG, bu21013_init_chip()
407 dev_err(&i2c->dev, "BU21013_REG_DONE reg write failed\n"); bu21013_init_chip()
491 * bu21013_probe() - initializes the i2c-client touchscreen driver
492 * @client: i2c client structure pointer
493 * @id: i2c device id pointer
495 * This function used to initializes the i2c-client touchscreen
509 dev_err(&client->dev, "i2c smbus byte data not supported\n"); bu21013_probe()
619 * bu21013_remove() - removes the i2c-client touchscreen driver
620 * @client: i2c client structure pointer
622 * This function uses to remove the i2c-client
714 MODULE_DEVICE_TABLE(i2c, bu21013_id);
H A D88pm860x-ts.c15 #include <linux/i2c.h>
45 struct i2c_client *i2c; member in struct:pm860x_touch
60 ret = pm860x_bulk_read(touch->i2c, MEAS_TSIX_1, MEAS_LEN, buf); pm860x_touch_handler()
100 ret = pm860x_set_bits(touch->i2c, MEAS_EN3, data, data); pm860x_touch_open()
115 pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0); pm860x_touch_close()
124 struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ pm860x_touch_dt_init() local
145 ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); pm860x_touch_dt_init()
151 ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); pm860x_touch_dt_init()
162 ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); pm860x_touch_dt_init()
178 struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ pm860x_touch_probe() local
201 ret = pm860x_reg_write(i2c, pm860x_touch_probe()
209 ret = pm860x_reg_write(i2c, pm860x_touch_probe()
221 ret = pm860x_reg_write(i2c, pm860x_touch_probe()
233 ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, PM8607_GPADC_EN, pm860x_touch_probe()
258 touch->i2c = i2c; pm860x_touch_probe()
/linux-4.4.14/drivers/base/regmap/
H A Dregmap-i2c.c14 #include <linux/i2c.h>
23 struct i2c_client *i2c = to_i2c_client(dev); regmap_smbus_byte_reg_read() local
29 ret = i2c_smbus_read_byte_data(i2c, reg); regmap_smbus_byte_reg_read()
42 struct i2c_client *i2c = to_i2c_client(dev); regmap_smbus_byte_reg_write() local
47 return i2c_smbus_write_byte_data(i2c, reg, val); regmap_smbus_byte_reg_write()
59 struct i2c_client *i2c = to_i2c_client(dev); regmap_smbus_word_reg_read() local
65 ret = i2c_smbus_read_word_data(i2c, reg); regmap_smbus_word_reg_read()
78 struct i2c_client *i2c = to_i2c_client(dev); regmap_smbus_word_reg_write() local
83 return i2c_smbus_write_word_data(i2c, reg, val); regmap_smbus_word_reg_write()
95 struct i2c_client *i2c = to_i2c_client(dev); regmap_smbus_word_read_swapped() local
101 ret = i2c_smbus_read_word_swapped(i2c, reg); regmap_smbus_word_read_swapped()
114 struct i2c_client *i2c = to_i2c_client(dev); regmap_smbus_word_write_swapped() local
119 return i2c_smbus_write_word_swapped(i2c, reg, val); regmap_smbus_word_write_swapped()
130 struct i2c_client *i2c = to_i2c_client(dev); regmap_i2c_write() local
133 ret = i2c_master_send(i2c, data, count); regmap_i2c_write()
147 struct i2c_client *i2c = to_i2c_client(dev); regmap_i2c_gather_write() local
154 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_NOSTART)) regmap_i2c_gather_write()
157 xfer[0].addr = i2c->addr; regmap_i2c_gather_write()
162 xfer[1].addr = i2c->addr; regmap_i2c_gather_write()
167 ret = i2c_transfer(i2c->adapter, xfer, 2); regmap_i2c_gather_write()
181 struct i2c_client *i2c = to_i2c_client(dev); regmap_i2c_read() local
185 xfer[0].addr = i2c->addr; regmap_i2c_read()
190 xfer[1].addr = i2c->addr; regmap_i2c_read()
195 ret = i2c_transfer(i2c->adapter, xfer, 2); regmap_i2c_read()
216 struct i2c_client *i2c = to_i2c_client(dev); regmap_i2c_smbus_i2c_write() local
224 return i2c_smbus_write_i2c_block_data(i2c, ((u8 *)data)[0], count, regmap_i2c_smbus_i2c_write()
233 struct i2c_client *i2c = to_i2c_client(dev); regmap_i2c_smbus_i2c_read() local
241 ret = i2c_smbus_read_i2c_block_data(i2c, ((u8 *)reg)[0], val_size, val); regmap_i2c_smbus_i2c_read()
257 static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c, regmap_get_i2c_bus() argument
260 if (i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C)) regmap_get_i2c_bus()
263 i2c_check_functionality(i2c->adapter, regmap_get_i2c_bus()
267 i2c_check_functionality(i2c->adapter, regmap_get_i2c_bus()
269 switch (regmap_get_val_endian(&i2c->dev, NULL, config)) { regmap_get_i2c_bus()
278 i2c_check_functionality(i2c->adapter, regmap_get_i2c_bus()
285 struct regmap *__regmap_init_i2c(struct i2c_client *i2c, __regmap_init_i2c() argument
290 const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config); __regmap_init_i2c()
295 return __regmap_init(&i2c->dev, bus, &i2c->dev, config, __regmap_init_i2c()
300 struct regmap *__devm_regmap_init_i2c(struct i2c_client *i2c, __devm_regmap_init_i2c() argument
305 const struct regmap_bus *bus = regmap_get_i2c_bus(i2c, config); __devm_regmap_init_i2c()
310 return __devm_regmap_init(&i2c->dev, bus, &i2c->dev, config, __devm_regmap_init_i2c()
H A DMakefile8 obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
/linux-4.4.14/drivers/media/dvb-frontends/
H A Ddvb-pll.h8 #include <linux/i2c.h>
36 * @param pll_addr i2c address of the PLL (if used).
37 * @param i2c i2c adapter to use (set to NULL if not used).
44 struct i2c_adapter *i2c,
49 struct i2c_adapter *i2c, dvb_pll_attach()
47 dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, unsigned int pll_desc_id) dvb_pll_attach() argument
H A Dsp887x.h13 /* the demodulator's i2c address */
22 struct i2c_adapter* i2c);
25 struct i2c_adapter* i2c) sp887x_attach()
24 sp887x_attach(const struct sp887x_config* config, struct i2c_adapter* i2c) sp887x_attach() argument
H A Dtda18271c2dd.h8 struct i2c_adapter *i2c, u8 adr);
11 struct i2c_adapter *i2c, u8 adr) tda18271c2dd_attach()
10 tda18271c2dd_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 adr) tda18271c2dd_attach() argument
H A Dsi21xx.h9 /* the demodulator's i2c address */
18 struct i2c_adapter *i2c);
21 const struct si21xx_config *config, struct i2c_adapter *i2c) si21xx_attach()
20 si21xx_attach( const struct si21xx_config *config, struct i2c_adapter *i2c) si21xx_attach() argument
H A Dcxd2841er.h34 struct i2c_adapter *i2c);
37 struct i2c_adapter *i2c);
40 struct i2c_adapter *i2c);
44 struct i2c_adapter *i2c) cxd2841er_attach_s()
51 struct cxd2841er_config *cfg, struct i2c_adapter *i2c) cxd2841er_attach_t()
58 struct cxd2841er_config *cfg, struct i2c_adapter *i2c) cxd2841er_attach_c()
42 cxd2841er_attach_s( struct cxd2841er_config *cfg, struct i2c_adapter *i2c) cxd2841er_attach_s() argument
50 cxd2841er_attach_t( struct cxd2841er_config *cfg, struct i2c_adapter *i2c) cxd2841er_attach_t() argument
57 cxd2841er_attach_c( struct cxd2841er_config *cfg, struct i2c_adapter *i2c) cxd2841er_attach_c() argument
H A Dstb6000.h27 #include <linux/i2c.h>
34 * @param addr i2c address of the tuner.
35 * @param i2c i2c adapter to use.
40 struct i2c_adapter *i2c);
44 struct i2c_adapter *i2c) stb6000_attach()
42 stb6000_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) stb6000_attach() argument
H A Dtda826x.h26 #include <linux/i2c.h>
33 * @param addr i2c address of the tuner.
34 * @param i2c i2c adapter to use.
40 struct i2c_adapter *i2c,
45 struct i2c_adapter *i2c, tda826x_attach()
43 tda826x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, int has_loopthrough) tda826x_attach() argument
H A Dlnbh25.c31 * @i2c: pointer to the I2C adapter structure
39 struct i2c_adapter *i2c; member in struct:lnbh25_priv
69 ret = i2c_transfer(priv->i2c, &msg[i], 1); lnbh25_read_vmon()
73 dev_dbg(&priv->i2c->dev, lnbh25_read_vmon()
82 dev_err(&priv->i2c->dev, lnbh25_read_vmon()
121 dev_dbg(&priv->i2c->dev, lnbh25_set_voltage()
125 ret = i2c_transfer(priv->i2c, &msg, 1); lnbh25_set_voltage()
129 dev_err(&priv->i2c->dev, "%s(): I2C transfer error (%d)\n", lnbh25_set_voltage()
147 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); lnbh25_release()
155 struct i2c_adapter *i2c) lnbh25_attach()
159 dev_dbg(&i2c->dev, "%s()\n", __func__); lnbh25_attach()
164 priv->i2c = i2c; lnbh25_attach()
170 dev_err(&i2c->dev, lnbh25_attach()
181 dev_err(&i2c->dev, "%s(): attached at I2C addr 0x%02x\n", lnbh25_attach()
153 lnbh25_attach(struct dvb_frontend *fe, struct lnbh25_config *cfg, struct i2c_adapter *i2c) lnbh25_attach() argument
H A Dcxd2820r_core.c28 static int cxd2820r_wr_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg, cxd2820r_wr_regs_i2c() argument
35 .addr = i2c, cxd2820r_wr_regs_i2c()
43 dev_warn(&priv->i2c->dev, cxd2820r_wr_regs_i2c()
44 "%s: i2c wr reg=%04x: len=%d is too big!\n", cxd2820r_wr_regs_i2c()
52 ret = i2c_transfer(priv->i2c, msg, 1); cxd2820r_wr_regs_i2c()
56 dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ cxd2820r_wr_regs_i2c()
64 static int cxd2820r_rd_regs_i2c(struct cxd2820r_priv *priv, u8 i2c, u8 reg, cxd2820r_rd_regs_i2c() argument
71 .addr = i2c, cxd2820r_rd_regs_i2c()
76 .addr = i2c, cxd2820r_rd_regs_i2c()
84 dev_warn(&priv->i2c->dev, cxd2820r_rd_regs_i2c()
85 "%s: i2c wr reg=%04x: len=%d is too big!\n", cxd2820r_rd_regs_i2c()
90 ret = i2c_transfer(priv->i2c, msg, 2); cxd2820r_rd_regs_i2c()
95 dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ cxd2820r_rd_regs_i2c()
111 u8 i2c = (reginfo >> 16) & 0x01; cxd2820r_wr_regs() local
114 if (i2c) cxd2820r_wr_regs()
120 if (bank != priv->bank[i2c]) { cxd2820r_wr_regs()
124 priv->bank[i2c] = bank; cxd2820r_wr_regs()
137 u8 i2c = (reginfo >> 16) & 0x01; cxd2820r_rd_regs() local
140 if (i2c) cxd2820r_rd_regs()
146 if (bank != priv->bank[i2c]) { cxd2820r_rd_regs()
150 priv->bank[i2c] = bank; cxd2820r_rd_regs()
194 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_gpio()
222 dev_dbg(&priv->i2c->dev, "%s: gpio i=%d %02x %02x\n", __func__, cxd2820r_gpio()
226 dev_dbg(&priv->i2c->dev, "%s: wr gpio=%02x %02x\n", __func__, tmp0, cxd2820r_gpio()
243 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); cxd2820r_gpio()
253 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_set_frontend()
282 dev_dbg(&priv->i2c->dev, "%s: error state=%d\n", __func__, cxd2820r_set_frontend()
296 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_read_status()
321 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_get_frontend()
349 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_read_ber()
374 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_read_signal_strength()
399 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_read_snr()
424 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_read_ucblocks()
454 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_sleep()
480 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_get_tune_settings()
507 dev_dbg(&priv->i2c->dev, "%s: delsys=%d\n", __func__, cxd2820r_search()
550 dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); cxd2820r_search()
570 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); cxd2820r_search()
583 dev_dbg(&priv->i2c->dev, "%s\n", __func__); cxd2820r_release()
599 dev_dbg(&priv->i2c->dev, "%s: %d\n", __func__, enable); cxd2820r_i2c_gate_ctrl()
613 dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val); cxd2820r_gpio_direction_output()
627 dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val); cxd2820r_gpio_set()
642 dev_dbg(&priv->i2c->dev, "%s: nr=%d\n", __func__, nr); cxd2820r_gpio_get()
695 struct i2c_adapter *i2c, int *gpio_chip_base cxd2820r_attach()
705 dev_err(&i2c->dev, "%s: kzalloc() failed\n", cxd2820r_attach()
710 priv->i2c = i2c; cxd2820r_attach()
717 dev_dbg(&priv->i2c->dev, "%s: chip id=%02x\n", __func__, tmp); cxd2820r_attach()
725 priv->gpio_chip.dev = &priv->i2c->dev; cxd2820r_attach()
738 dev_dbg(&priv->i2c->dev, "%s: gpio_chip.base=%d\n", __func__, cxd2820r_attach()
759 dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); cxd2820r_attach()
694 cxd2820r_attach(const struct cxd2820r_config *cfg, struct i2c_adapter *i2c, int *gpio_chip_base ) cxd2820r_attach() argument
H A Dstb6000.c38 /* i2c details */
40 struct i2c_adapter *i2c; member in struct:stb6000_priv
68 ret = i2c_transfer(priv->i2c, &msg, 1); stb6000_sleep()
70 dprintk("%s: i2c error\n", __func__); stb6000_sleep()
149 ret = i2c_transfer(priv->i2c, &msg, 1); stb6000_set_params()
151 dprintk("%s: i2c error\n", __func__); stb6000_set_params()
167 ret = i2c_transfer(priv->i2c, &msg, 1); stb6000_set_params()
169 dprintk("%s: i2c error\n", __func__); stb6000_set_params()
202 struct i2c_adapter *i2c) stb6000_attach()
227 /* is some i2c device here ? */ stb6000_attach()
228 ret = i2c_transfer(i2c, msg, 2); stb6000_attach()
240 priv->i2c = i2c; stb6000_attach()
201 stb6000_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) stb6000_attach() argument
H A Ddrxd.h29 #include <linux/i2c.h>
47 /* If the tuner is not behind an i2c gate, be sure to flip this bit
48 or else the i2c bus could get wedged */
58 void *priv, struct i2c_adapter *i2c,
63 void *priv, struct i2c_adapter *i2c, drxd_attach()
62 drxd_attach(const struct drxd_config *config, void *priv, struct i2c_adapter *i2c, struct device *dev) drxd_attach() argument
H A Ds921.h24 /* the demodulator's i2c address */
30 struct i2c_adapter *i2c);
34 const struct s921_config *config, struct i2c_adapter *i2c) s921_attach()
33 s921_attach( const struct s921_config *config, struct i2c_adapter *i2c) s921_attach() argument
H A Dtda1002x.h30 /* the demodulator's i2c address */
43 /* the demodulator's i2c address */
62 struct i2c_adapter* i2c, u8 pwm);
65 struct i2c_adapter* i2c, u8 pwm) tda10021_attach()
75 struct i2c_adapter *i2c, u8 pwm);
79 struct i2c_adapter *i2c, u8 pwm) tda10023_attach()
64 tda10021_attach(const struct tda1002x_config* config, struct i2c_adapter* i2c, u8 pwm) tda10021_attach() argument
77 tda10023_attach( const struct tda10023_config *config, struct i2c_adapter *i2c, u8 pwm) tda10023_attach() argument
H A Dlnbp21.c43 struct i2c_adapter *i2c; member in struct:lnbp21
73 return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO; lnbp21_set_voltage()
91 return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO; lnbp21_enable_high_lnb_voltage()
116 return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO; lnbp21_set_tone()
130 struct i2c_adapter *i2c, u8 override_set, lnbx2x_attach()
139 lnbp21->i2c = i2c; lnbx2x_attach()
169 struct i2c_adapter *i2c, u8 override_set, lnbh24_attach()
172 return lnbx2x_attach(fe, i2c, override_set, override_clear, lnbh24_attach()
178 struct i2c_adapter *i2c, u8 override_set, lnbp21_attach()
181 return lnbx2x_attach(fe, i2c, override_set, override_clear, lnbp21_attach()
129 lnbx2x_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear, u8 i2c_addr, u8 config) lnbx2x_attach() argument
168 lnbh24_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear, u8 i2c_addr) lnbh24_attach() argument
177 lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear) lnbp21_attach() argument
H A Dtua6100.c39 /* i2c details */
41 struct i2c_adapter *i2c; member in struct:tua6100_priv
61 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { tua6100_sleep()
62 printk("%s: i2c error\n", __func__); tua6100_sleep()
134 if (i2c_transfer(priv->i2c, &msg0, 1) != 1) tua6100_set_params()
139 if (i2c_transfer(priv->i2c, &msg2, 1) != 1) tua6100_set_params()
144 if (i2c_transfer(priv->i2c, &msg1, 1) != 1) tua6100_set_params()
173 struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) tua6100_attach() argument
184 ret = i2c_transfer (i2c, msg, 2); tua6100_attach()
196 priv->i2c = i2c; tua6100_attach()
H A Dcx24117.c34 #include "tuner-i2c.h"
199 struct i2c_adapter *i2c; member in struct:cx24117_priv
276 dev_dbg(&state->priv->i2c->dev, cx24117_writereg()
277 "%s() demod%d i2c wr @0x%02x=0x%02x\n", cx24117_writereg()
280 ret = i2c_transfer(state->priv->i2c, &msg, 1); cx24117_writereg()
282 dev_warn(&state->priv->i2c->dev, cx24117_writereg()
283 "%s: demod%d i2c wr err(%i) @0x%02x=0x%02x\n", cx24117_writereg()
297 dev_dbg(&state->priv->i2c->dev, cx24117_writecmd()
298 "%s() demod%d i2c wr cmd len=%d\n", cx24117_writecmd()
308 ret = i2c_transfer(state->priv->i2c, &msg, 1); cx24117_writecmd()
310 dev_warn(&state->priv->i2c->dev, cx24117_writecmd()
311 "%s: demod%d i2c wr cmd err(%i) len=%d\n", cx24117_writecmd()
329 ret = i2c_transfer(state->priv->i2c, msg, 2); cx24117_readreg()
331 dev_warn(&state->priv->i2c->dev, cx24117_readreg()
332 "%s: demod%d i2c rd err(%d) @0x%x\n", cx24117_readreg()
337 dev_dbg(&state->priv->i2c->dev, "%s() demod%d i2c rd @0x%02x=0x%02x\n", cx24117_readreg()
354 ret = i2c_transfer(state->priv->i2c, msg, 2); cx24117_readregN()
356 dev_warn(&state->priv->i2c->dev, cx24117_readregN()
357 "%s: demod%d i2c rd err(%d) @0x%x\n", cx24117_readregN()
367 dev_dbg(&state->priv->i2c->dev, "%s(%d) demod%d\n", cx24117_set_inversion()
394 dev_dbg(&state->priv->i2c->dev, cx24117_lookup_fecmod()
417 dev_dbg(&state->priv->i2c->dev, cx24117_set_fec()
428 dev_dbg(&state->priv->i2c->dev, cx24117_set_fec()
437 dev_dbg(&state->priv->i2c->dev, "%s(%d) demod%d\n", cx24117_set_symbolrate()
442 dev_dbg(&state->priv->i2c->dev, cx24117_set_symbolrate()
458 dev_dbg(&state->priv->i2c->dev, "%s() demod%d skip_fw_load=%d\n", cx24117_firmware_ondemand()
468 dev_dbg(&state->priv->i2c->dev, cx24117_firmware_ondemand()
472 state->priv->i2c->dev.parent); cx24117_firmware_ondemand()
473 dev_dbg(&state->priv->i2c->dev, cx24117_firmware_ondemand()
476 dev_err(&state->priv->i2c->dev, cx24117_firmware_ondemand()
488 dev_err(&state->priv->i2c->dev, cx24117_firmware_ondemand()
492 dev_info(&state->priv->i2c->dev, cx24117_firmware_ondemand()
512 dev_dbg(&state->priv->i2c->dev, "%s() demod%d\n", cx24117_cmd_execute_nolock()
531 dev_warn(&state->priv->i2c->dev, cx24117_cmd_execute_nolock()
562 dev_dbg(&state->priv->i2c->dev, cx24117_load_firmware()
626 /* prepare i2c message to send */ cx24117_load_firmware()
633 ret = i2c_transfer(state->priv->i2c, &msg, 1); cx24117_load_firmware()
732 dev_info(&state->priv->i2c->dev, cx24117_load_firmware()
738 dev_err(&state->priv->i2c->dev, "%s() Error running FW.\n", __func__); cx24117_load_firmware()
752 dev_dbg(&state->priv->i2c->dev, "%s() demod%d status = 0x%02x\n", cx24117_read_status()
785 dev_dbg(&state->priv->i2c->dev, "%s() demod%d ber=0x%04x\n", cx24117_read_ber()
817 dev_dbg(&state->priv->i2c->dev, cx24117_read_signal_strength()
838 dev_dbg(&state->priv->i2c->dev, cx24117_read_snr()
870 dev_dbg(&state->priv->i2c->dev, "%s() demod%d ucb=0x%04x\n", cx24117_read_ucblocks()
891 dev_dbg(&state->priv->i2c->dev, "%s() demod%d qstatus = 0x%02x\n", cx24117_wait_for_lnb()
902 dev_warn(&state->priv->i2c->dev, "%s: demod%d LNB not ready\n", cx24117_wait_for_lnb()
916 dev_dbg(&state->priv->i2c->dev, "%s() demod%d %s\n", cx24117_set_voltage()
967 dev_dbg(&state->priv->i2c->dev, "%s(%d) demod%d\n", cx24117_set_tone()
970 dev_warn(&state->priv->i2c->dev, "%s: demod%d invalid tone=%d\n", cx24117_set_tone()
1041 dev_dbg(&state->priv->i2c->dev, "%s: demod %d (", cx24117_send_diseqc_msg()
1044 dev_dbg(&state->priv->i2c->dev, "0x%02x ", d->msg[i]); cx24117_send_diseqc_msg()
1045 dev_dbg(&state->priv->i2c->dev, ")\n"); cx24117_send_diseqc_msg()
1084 dev_dbg(&state->priv->i2c->dev, "%s() demod%d burst=%d\n", cx24117_send_diseqc_msg()
1121 dev_dbg(&state->priv->i2c->dev, "%s(%d) demod=%d\n", cx24117_diseqc_send_burst()
1138 struct i2c_adapter *i2c, u8 client_address) cx24117_get_priv()
1144 hybrid_tuner_instance_list, i2c, client_address, "cx24117"); cx24117_get_priv()
1161 dev_dbg(&state->priv->i2c->dev, "%s demod%d\n", cx24117_release()
1170 struct i2c_adapter *i2c) cx24117_attach()
1177 demod = cx24117_get_priv(&priv, i2c, config->demod_address); cx24117_attach()
1181 dev_err(&i2c->dev, cx24117_attach()
1188 priv->i2c = i2c; cx24117_attach()
1205 dev_info(&state->priv->i2c->dev, cx24117_attach()
1233 dev_dbg(&state->priv->i2c->dev, "%s() demod%d\n", cx24117_initfe()
1292 dev_dbg(&state->priv->i2c->dev, "%s() demod%d\n", cx24117_sleep()
1315 dev_dbg(&state->priv->i2c->dev, "%s() demod%d\n", cx24117_set_frontend()
1320 dev_dbg(&state->priv->i2c->dev, "%s() demod%d DVB-S\n", cx24117_set_frontend()
1325 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1339 dev_dbg(&state->priv->i2c->dev, "%s() demod%d DVB-S2\n", cx24117_set_frontend()
1347 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1364 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1386 dev_warn(&state->priv->i2c->dev, cx24117_set_frontend()
1394 dev_warn(&state->priv->i2c->dev, cx24117_set_frontend()
1422 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1424 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1426 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1428 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1431 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1433 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1436 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1438 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1441 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1500 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1522 dev_dbg(&state->priv->i2c->dev, cx24117_set_frontend()
1530 dev_dbg(&state->priv->i2c->dev, "%s() demod%d not tuned\n", cx24117_set_frontend()
1546 dev_dbg(&state->priv->i2c->dev, "%s() demod%d\n", cx24117_tune()
1137 cx24117_get_priv(struct cx24117_priv **priv, struct i2c_adapter *i2c, u8 client_address) cx24117_get_priv() argument
1169 cx24117_attach(const struct cx24117_config *config, struct i2c_adapter *i2c) cx24117_attach() argument
H A Daf9013.c31 struct i2c_adapter *i2c; member in struct:af9013_state
67 dev_warn(&priv->i2c->dev, af9013_wr_regs_i2c()
68 "%s: i2c wr reg=%04x: len=%d is too big!\n", af9013_wr_regs_i2c()
78 ret = i2c_transfer(priv->i2c, msg, 1); af9013_wr_regs_i2c()
82 dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%04x " \ af9013_wr_regs_i2c()
113 ret = i2c_transfer(priv->i2c, msg, 2); af9013_rd_regs_i2c()
117 dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%04x " \ af9013_rd_regs_i2c()
231 dev_dbg(&state->i2c->dev, "%s: gpio=%d gpioval=%02x\n", af9013_set_gpio()
250 dev_err(&state->i2c->dev, "%s: invalid gpio=%d\n", af9013_set_gpio()
274 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_set_gpio()
282 dev_dbg(&state->i2c->dev, "%s: a=%d b=%d x=%d\n", __func__, a, b, x); af9013_div()
299 dev_dbg(&state->i2c->dev, "%s: a=%d b=%d x=%d r=%d r=%x\n", af9013_div()
310 dev_dbg(&state->i2c->dev, "%s: onoff=%d\n", __func__, onoff); af9013_power_ctrl()
355 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_power_ctrl()
364 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_statistics_ber_unc_start()
373 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_statistics_ber_unc_start()
383 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_statistics_ber_unc_result()
391 dev_dbg(&state->i2c->dev, "%s: not ready\n", __func__); af9013_statistics_ber_unc_result()
404 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_statistics_ber_unc_result()
413 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_statistics_snr_start()
422 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_statistics_snr_start()
434 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_statistics_snr_result()
442 dev_dbg(&state->i2c->dev, "%s: not ready\n", __func__); af9013_statistics_snr_result()
485 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_statistics_snr_result()
496 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_statistics_signal_strength()
522 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_statistics_signal_strength()
592 dev_dbg(&state->i2c->dev, "%s: frequency=%d bandwidth_hz=%d\n", af9013_set_frontend()
624 dev_dbg(&state->i2c->dev, "%s: if_frequency=%d\n", af9013_set_frontend()
698 dev_dbg(&state->i2c->dev, "%s: invalid transmission_mode\n", af9013_set_frontend()
719 dev_dbg(&state->i2c->dev, "%s: invalid guard_interval\n", af9013_set_frontend()
740 dev_dbg(&state->i2c->dev, "%s: invalid hierarchy\n", __func__); af9013_set_frontend()
757 dev_dbg(&state->i2c->dev, "%s: invalid modulation\n", __func__); af9013_set_frontend()
783 dev_dbg(&state->i2c->dev, "%s: invalid code_rate_HP\n", af9013_set_frontend()
809 dev_dbg(&state->i2c->dev, "%s: invalid code_rate_LP\n", af9013_set_frontend()
824 dev_dbg(&state->i2c->dev, "%s: invalid bandwidth_hz\n", af9013_set_frontend()
840 dev_dbg(&state->i2c->dev, "%s: auto params\n", __func__); af9013_set_frontend()
851 dev_dbg(&state->i2c->dev, "%s: manual params\n", __func__); af9013_set_frontend()
865 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_set_frontend()
876 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_get_frontend()
982 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_get_frontend()
1032 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_read_status()
1072 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_init()
1104 dev_err(&state->i2c->dev, "%s: invalid clock\n", af9013_init()
1165 dev_dbg(&state->i2c->dev, "%s: load ofsm settings\n", __func__); af9013_init()
1176 dev_dbg(&state->i2c->dev, "%s: load tuner specific settings\n", af9013_init()
1288 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_init()
1297 dev_dbg(&state->i2c->dev, "%s:\n", __func__); af9013_sleep()
1314 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_sleep()
1323 dev_dbg(&state->i2c->dev, "%s: enable=%d\n", __func__, enable); af9013_i2c_gate_ctrl()
1340 dev_dbg(&state->i2c->dev, "%s: failed=%d\n", __func__, ret); af9013_i2c_gate_ctrl()
1367 dev_dbg(&state->i2c->dev, "%s: firmware status=%02x\n", af9013_download_firmware()
1373 dev_info(&state->i2c->dev, "%s: found a '%s' in cold state, will try " \ af9013_download_firmware()
1378 ret = request_firmware(&fw, fw_file, state->i2c->dev.parent); af9013_download_firmware()
1380 dev_info(&state->i2c->dev, "%s: did not find the firmware " \ af9013_download_firmware()
1387 dev_info(&state->i2c->dev, "%s: downloading firmware from file '%s'\n", af9013_download_firmware()
1416 dev_err(&state->i2c->dev, af9013_download_firmware()
1436 dev_dbg(&state->i2c->dev, "%s: firmware status=%02x\n", af9013_download_firmware()
1444 dev_err(&state->i2c->dev, "%s: firmware did not run\n", af9013_download_firmware()
1448 dev_err(&state->i2c->dev, "%s: firmware boot timeout\n", af9013_download_firmware()
1458 dev_info(&state->i2c->dev, "%s: found a '%s' in warm state\n", af9013_download_firmware()
1464 struct i2c_adapter *i2c) af9013_attach()
1476 state->i2c = i2c; af9013_attach()
1491 dev_info(&state->i2c->dev, "%s: firmware version %d.%d.%d.%d\n", af9013_attach()
1463 af9013_attach(const struct af9013_config *config, struct i2c_adapter *i2c) af9013_attach() argument
H A Dhorus3a.c40 struct i2c_adapter *i2c; member in struct:horus3a_priv
49 dev_dbg(&priv->i2c->dev, "horus3a: I2C %s reg 0x%02x size %d\n", horus3a_i2c_debug()
70 dev_warn(&priv->i2c->dev,"wr reg=%04x: len=%d is too big!\n", horus3a_write_regs()
78 ret = i2c_transfer(priv->i2c, msg, 1); horus3a_write_regs()
82 dev_warn(&priv->i2c->dev, horus3a_write_regs()
83 "%s: i2c wr failed=%d reg=%02x len=%d\n", horus3a_write_regs()
99 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); horus3a_enter_power_save()
126 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); horus3a_leave_power_save()
150 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); horus3a_init()
158 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); horus3a_release()
168 dev_dbg(&priv->i2c->dev, "%s()\n", __func__); horus3a_sleep()
187 dev_dbg(&priv->i2c->dev, "%s(): frequency %dkHz symbol_rate %dksps\n", horus3a_set_params()
206 dev_err(&priv->i2c->dev, "horus3a: invalid frequency %d\n", horus3a_set_params()
289 dev_err(&priv->i2c->dev, horus3a_set_params()
314 dev_err(&priv->i2c->dev, horus3a_set_params()
365 struct i2c_adapter *i2c) horus3a_attach()
374 priv->i2c = i2c; horus3a_attach()
405 dev_warn(&priv->i2c->dev, horus3a_attach()
421 dev_info(&priv->i2c->dev, horus3a_attach()
423 priv->i2c_address, priv->i2c); horus3a_attach()
363 horus3a_attach(struct dvb_frontend *fe, const struct horus3a_config *config, struct i2c_adapter *i2c) horus3a_attach() argument
H A Datbm8830.h27 #include <linux/i2c.h>
37 /* the demodulator's i2c address */
66 struct i2c_adapter *i2c);
70 struct i2c_adapter *i2c) { atbm8830_attach()
69 atbm8830_attach(const struct atbm8830_config *config, struct i2c_adapter *i2c) atbm8830_attach() argument
H A Dcx24117.h29 /* the demodulator's i2c address */
36 struct i2c_adapter *i2c);
40 struct i2c_adapter *i2c) cx24117_attach()
42 dev_warn(&i2c->dev, "%s: driver disabled by Kconfig\n", __func__); cx24117_attach()
38 cx24117_attach( const struct cx24117_config *config, struct i2c_adapter *i2c) cx24117_attach() argument
H A Dstv0297.h29 /* the demodulator's i2c address */
41 /* set to 1 if the device requires an i2c STOP during reading */
47 struct i2c_adapter* i2c);
50 struct i2c_adapter* i2c) stv0297_attach()
49 stv0297_attach(const struct stv0297_config* config, struct i2c_adapter* i2c) stv0297_attach() argument
H A Dstv0367.h45 struct i2c_adapter *i2c);
48 struct i2c_adapter *i2c);
52 struct i2c_adapter *i2c) stv0367ter_attach()
59 struct i2c_adapter *i2c) stv0367cab_attach()
51 stv0367ter_attach(const struct stv0367_config *config, struct i2c_adapter *i2c) stv0367ter_attach() argument
58 stv0367cab_attach(const struct stv0367_config *config, struct i2c_adapter *i2c) stv0367cab_attach() argument
H A Dzl10039.c47 struct i2c_adapter *i2c; member in struct:zl10039_state
92 if (i2c_transfer(state->i2c, msg, 2) != 2) { zl10039_read()
93 dprintk("%s: i2c read error\n", __func__); zl10039_read()
114 "%s: i2c wr reg=%04x: len=%zu is too big!\n", zl10039_write()
123 if (i2c_transfer(state->i2c, &msg, 1) != 1) { zl10039_write()
124 dprintk("%s: i2c write error\n", __func__); zl10039_write()
155 dprintk("Note: i2c write error normal when resetting the " zl10039_init()
223 /* Open i2c gate */ zl10039_set_params()
239 /* Close i2c gate */ zl10039_set_params()
266 u8 i2c_addr, struct i2c_adapter *i2c) zl10039_attach()
275 state->i2c = i2c; zl10039_attach()
278 /* Open i2c gate */ zl10039_attach()
283 /* Close i2c gate */ zl10039_attach()
288 /* Close i2c gate */ zl10039_attach()
305 dprintk("Tuner attached @ i2c address 0x%02x\n", i2c_addr); zl10039_attach()
265 zl10039_attach(struct dvb_frontend *fe, u8 i2c_addr, struct i2c_adapter *i2c) zl10039_attach() argument
H A Dtda826x.c37 /* i2c details */
39 struct i2c_adapter *i2c; member in struct:tda826x_priv
65 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { tda826x_sleep()
66 dprintk("%s: i2c error\n", __func__); tda826x_sleep()
114 if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { tda826x_set_params()
115 dprintk("%s: i2c error\n", __func__); tda826x_set_params()
144 struct dvb_frontend *tda826x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, int has_loopthrough) tda826x_attach() argument
158 ret = i2c_transfer (i2c, msg, 2); tda826x_attach()
172 priv->i2c = i2c; tda826x_attach()
/linux-4.4.14/drivers/media/pci/cx88/
H A DMakefile1 cx88xx-objs := cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o \
11 obj-$(CONFIG_VIDEO_CX88_VP3054) += cx88-vp3054-i2c.o
13 ccflags-y += -Idrivers/media/i2c
H A Dcx88-i2c.c4 cx88-i2c.c -- all the i2c code is here
12 - Multituner support and i2c address binding
40 MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]");
44 MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
48 MODULE_PARM_DESC(i2c_udelay,"i2c delay at insmod time, in usecs "
130 printk("%s: i2c scan: found device @ 0x%x [%s]\n", do_i2c_scan()
135 /* init + register i2c adapter */ cx88_i2c_init()
165 dprintk(1, "i2c register ok\n"); cx88_i2c_init()
170 printk("%s: i2c init: enabling analog demod on HVR1300/3000/4000 tuner\n", cx88_i2c_init()
180 printk("%s: i2c register FAILED\n", core->name); cx88_i2c_init()
/linux-4.4.14/drivers/staging/sm750fb/
H A Dddk750_swi2c.h9 * This file contains the definitions for i2c using software
16 /* Default i2c CLK and Data GPIO. These are the default i2c pins */
21 * This function initializes the i2c attributes and bus
24 * i2cClkGPIO - The GPIO pin to be used as i2c SCL
25 * i2cDataGPIO - The GPIO pin to be used as i2c SDA
28 * -1 - Fail to initialize the i2c
40 * addr - i2c Slave device address which register
56 * addr - i2c Slave device address which register
/linux-4.4.14/drivers/video/fbdev/riva/
H A DMakefile10 rivafb-objs += rivafb-i2c.o
/linux-4.4.14/drivers/macintosh/ams/
H A DMakefile7 ams-$(CONFIG_SENSORS_AMS_I2C) += ams-i2c.o
/linux-4.4.14/drivers/media/pci/cobalt/
H A DMakefile2 cobalt-i2c.o cobalt-omnitek.o cobalt-flash.o cobalt-cpld.o \
/linux-4.4.14/drivers/media/pci/solo6x10/
H A DMakefile1 solo6x10-y := solo6x10-core.o solo6x10-i2c.o solo6x10-p2m.o solo6x10-v4l2.o \
/linux-4.4.14/drivers/nfc/microread/
H A DMakefile5 microread_i2c-objs = i2c.o
/linux-4.4.14/drivers/nfc/nxp-nci/
H A DMakefile6 nxp-nci_i2c-objs = i2c.o
/linux-4.4.14/drivers/nfc/pn544/
H A DMakefile5 pn544_i2c-objs = i2c.o
/linux-4.4.14/drivers/nfc/st21nfca/
H A DMakefile8 st21nfca_i2c-objs = i2c.o
/linux-4.4.14/drivers/char/tpm/st33zp24/
H A DMakefile8 tpm_st33zp24_i2c-objs = i2c.o
/linux-4.4.14/drivers/media/common/b2c2/
H A Dflexcop-i2c.c3 * flexcop-i2c.c - flexcop internal 2Wire bus (I2C) and dvb i2c initialization
20 fc->write_ibi_reg(fc, tw_sm_c_100, *r100); /* initiating i2c operation */ flexcop_i2c_operation()
28 deb_i2c("i2c success\n"); flexcop_i2c_operation()
32 deb_i2c("suffering from an i2c ack_error\n"); flexcop_i2c_operation()
36 deb_i2c("tried %d times i2c operation, " flexcop_i2c_operation()
41 static int flexcop_i2c_read4(struct flexcop_i2c_adapter *i2c, flexcop_i2c_read4() argument
52 * the ITD1000 is behind an i2c-gate which closes automatically flexcop_i2c_read4()
53 * after an i2c-transaction the STV0297 needs 2 consecutive reads flexcop_i2c_read4()
58 if (i2c->fc->dev_type == FC_SKY_REV27) flexcop_i2c_read4()
59 r100.tw_sm_c_100.no_base_addr_ack_error = i2c->no_base_addr; flexcop_i2c_read4()
61 ret = flexcop_i2c_operation(i2c->fc, &r100); flexcop_i2c_read4()
64 r100.tw_sm_c_100.no_base_addr_ack_error = i2c->no_base_addr; flexcop_i2c_read4()
65 ret = flexcop_i2c_operation(i2c->fc, &r100); flexcop_i2c_read4()
75 r104 = i2c->fc->read_ibi_reg(i2c->fc, tw_sm_c_104); flexcop_i2c_read4()
101 /* write the additional i2c data before doing the actual i2c operation */ flexcop_i2c_write4()
106 int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c, flexcop_i2c_request() argument
122 r100.tw_sm_c_100.twoWS_port_reg = i2c->port; flexcop_i2c_request()
125 printk(KERN_DEBUG "%d ", i2c->port); flexcop_i2c_request()
136 if (i2c->no_base_addr && len == 0 && op == FC_WRITE) { flexcop_i2c_request()
148 ret = flexcop_i2c_read4(i2c, r100, buf); flexcop_i2c_request()
150 ret = flexcop_i2c_write4(i2c->fc, r100, buf); flexcop_i2c_request()
171 /* exported for PCI i2c */
178 struct flexcop_i2c_adapter *i2c = i2c_get_adapdata(i2c_adap); flexcop_master_xfer() local
188 if (mutex_lock_interruptible(&i2c->fc->i2c_mutex)) flexcop_master_xfer()
194 ret = i2c->fc->i2c_request(i2c, FC_READ, msgs[i].addr, flexcop_master_xfer()
199 ret = i2c->fc->i2c_request(i2c, FC_WRITE, msgs[i].addr, flexcop_master_xfer()
203 deb_i2c("i2c master_xfer failed"); flexcop_master_xfer()
208 mutex_unlock(&i2c->fc->i2c_mutex); flexcop_master_xfer()
/linux-4.4.14/drivers/gpu/drm/msm/hdmi/
H A Dhdmi_i2c.c100 static int hdmi_i2c_xfer(struct i2c_adapter *i2c, hdmi_i2c_xfer() argument
103 struct hdmi_i2c_adapter *hdmi_i2c = to_hdmi_i2c_adapter(i2c); hdmi_i2c_xfer()
229 void hdmi_i2c_irq(struct i2c_adapter *i2c) hdmi_i2c_irq() argument
231 struct hdmi_i2c_adapter *hdmi_i2c = to_hdmi_i2c_adapter(i2c); hdmi_i2c_irq()
237 void hdmi_i2c_destroy(struct i2c_adapter *i2c) hdmi_i2c_destroy() argument
239 struct hdmi_i2c_adapter *hdmi_i2c = to_hdmi_i2c_adapter(i2c); hdmi_i2c_destroy()
240 i2c_del_adapter(i2c); hdmi_i2c_destroy()
248 struct i2c_adapter *i2c = NULL; hdmi_i2c_init() local
257 i2c = &hdmi_i2c->base; hdmi_i2c_init()
263 i2c->owner = THIS_MODULE; hdmi_i2c_init()
264 i2c->class = I2C_CLASS_DDC; hdmi_i2c_init()
265 snprintf(i2c->name, sizeof(i2c->name), "msm hdmi i2c"); hdmi_i2c_init()
266 i2c->dev.parent = &hdmi->pdev->dev; hdmi_i2c_init()
267 i2c->algo = &hdmi_i2c_algorithm; hdmi_i2c_init()
269 ret = i2c_add_adapter(i2c); hdmi_i2c_init()
271 dev_err(dev->dev, "failed to register hdmi i2c: %d\n", ret); hdmi_i2c_init()
275 return i2c; hdmi_i2c_init()
278 if (i2c) hdmi_i2c_init()
279 hdmi_i2c_destroy(i2c); hdmi_i2c_init()
/linux-4.4.14/drivers/media/pci/bt8xx/
H A DMakefile2 bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \
10 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/media/pci/saa7164/
H A DMakefile1 saa7164-objs := saa7164-cards.o saa7164-core.o saa7164-i2c.o saa7164-dvb.o \
7 ccflags-y += -I$(srctree)/drivers/media/i2c
/linux-4.4.14/drivers/media/tuners/
H A Dmt2063.h14 struct i2c_adapter *i2c);
20 struct i2c_adapter *i2c) mt2063_attach()
18 mt2063_attach(struct dvb_frontend *fe, struct mt2063_config *config, struct i2c_adapter *i2c) mt2063_attach() argument
H A Dfc0011.h28 struct i2c_adapter *i2c,
33 struct i2c_adapter *i2c, fc0011_attach()
36 dev_err(&i2c->dev, "fc0011 driver disabled in Kconfig\n"); fc0011_attach()
32 fc0011_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct fc0011_config *config) fc0011_attach() argument
H A Dtda827x.h27 #include <linux/i2c.h>
49 * @param addr i2c address of the tuner.
50 * @param i2c i2c adapter to use.
56 struct i2c_adapter *i2c,
61 struct i2c_adapter *i2c, tda827x_attach()
59 tda827x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, struct tda827x_config *cfg) tda827x_attach() argument
H A Dtda18218.c40 dev_warn(&priv->i2c->dev, tda18218_wr_regs()
41 "%s: i2c wr reg=%04x: len=%d is too big!\n", tda18218_wr_regs()
56 ret = i2c_transfer(priv->i2c, msg, 1); tda18218_wr_regs()
64 dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ tda18218_wr_regs()
92 dev_warn(&priv->i2c->dev, tda18218_rd_regs()
93 "%s: i2c wr reg=%04x: len=%d is too big!\n", tda18218_rd_regs()
98 ret = i2c_transfer(priv->i2c, msg, 2); tda18218_rd_regs()
103 dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ tda18218_rd_regs()
214 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); tda18218_set_params()
223 dev_dbg(&priv->i2c->dev, "%s: if_frequency=%d\n", __func__, *frequency); tda18218_get_if_frequency()
242 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); tda18218_sleep()
263 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); tda18218_init()
294 struct i2c_adapter *i2c, struct tda18218_config *cfg) tda18218_attach()
314 priv->i2c = i2c; tda18218_attach()
323 dev_dbg(&priv->i2c->dev, "%s: chip id=%02x\n", __func__, val); tda18218_attach()
329 dev_info(&priv->i2c->dev, tda18218_attach()
346 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); tda18218_attach()
293 tda18218_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct tda18218_config *cfg) tda18218_attach() argument
H A Dqt1010.h35 * @param i2c i2c adapter to use
41 struct i2c_adapter *i2c,
45 struct i2c_adapter *i2c, qt1010_attach()
44 qt1010_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct qt1010_config *cfg) qt1010_attach() argument
/linux-4.4.14/drivers/media/usb/cx231xx/
H A DMakefile1 cx231xx-y += cx231xx-video.o cx231xx-i2c.o cx231xx-cards.o cx231xx-core.o
11 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/media/usb/em28xx/
H A DMakefile1 em28xx-y += em28xx-core.o em28xx-i2c.o em28xx-cards.o em28xx-camera.o
13 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/media/usb/tm6000/
H A DMakefile3 tm6000-i2c.o \
12 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/gpu/drm/radeon/
H A Dradeon_i2c.c88 /* bit banging i2c */
92 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); pre_xfer() local
93 struct radeon_device *rdev = i2c->dev->dev_private; pre_xfer()
94 struct radeon_i2c_bus_rec *rec = &i2c->rec; pre_xfer()
97 mutex_lock(&i2c->mutex); pre_xfer()
99 /* RV410 appears to have a bug where the hw i2c in reset pre_xfer()
100 * holds the i2c port in a bad state - switch hw i2c away before pre_xfer()
162 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); post_xfer() local
163 struct radeon_device *rdev = i2c->dev->dev_private; post_xfer()
164 struct radeon_i2c_bus_rec *rec = &i2c->rec; post_xfer()
176 mutex_unlock(&i2c->mutex); post_xfer()
181 struct radeon_i2c_chan *i2c = i2c_priv; get_clock() local
182 struct radeon_device *rdev = i2c->dev->dev_private; get_clock()
183 struct radeon_i2c_bus_rec *rec = &i2c->rec; get_clock()
196 struct radeon_i2c_chan *i2c = i2c_priv; get_data() local
197 struct radeon_device *rdev = i2c->dev->dev_private; get_data()
198 struct radeon_i2c_bus_rec *rec = &i2c->rec; get_data()
210 struct radeon_i2c_chan *i2c = i2c_priv; set_clock() local
211 struct radeon_device *rdev = i2c->dev->dev_private; set_clock()
212 struct radeon_i2c_bus_rec *rec = &i2c->rec; set_clock()
223 struct radeon_i2c_chan *i2c = i2c_priv; set_data() local
224 struct radeon_device *rdev = i2c->dev->dev_private; set_data()
225 struct radeon_i2c_bus_rec *rec = &i2c->rec; set_data()
234 /* hw i2c */
316 DRM_ERROR("i2c: unhandled radeon chip\n"); radeon_get_i2c_prescale()
323 /* hw i2c engine for r1xx-4xx hardware
329 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); r100_hw_i2c_xfer() local
330 struct radeon_device *rdev = i2c->dev->dev_private; r100_hw_i2c_xfer()
331 struct radeon_i2c_bus_rec *rec = &i2c->rec; r100_hw_i2c_xfer()
376 DRM_ERROR("gpio not supported with hw i2c\n"); r100_hw_i2c_xfer()
391 DRM_ERROR("gpio not supported with hw i2c\n"); r100_hw_i2c_xfer()
410 DRM_ERROR("gpio not supported with hw i2c\n"); r100_hw_i2c_xfer()
426 DRM_ERROR("gpio not supported with hw i2c\n"); r100_hw_i2c_xfer()
450 DRM_ERROR("gpio not supported with hw i2c\n"); r100_hw_i2c_xfer()
486 DRM_DEBUG("i2c write error 0x%08x\n", tmp); r100_hw_i2c_xfer()
518 DRM_DEBUG("i2c read error 0x%08x\n", tmp); r100_hw_i2c_xfer()
546 DRM_DEBUG("i2c write error 0x%08x\n", tmp); r100_hw_i2c_xfer()
576 /* hw i2c engine for r5xx hardware
582 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); r500_hw_i2c_xfer() local
583 struct radeon_device *rdev = i2c->dev->dev_private; r500_hw_i2c_xfer()
584 struct radeon_i2c_bus_rec *rec = &i2c->rec; r500_hw_i2c_xfer()
644 DRM_ERROR("failed to get i2c bus\n"); r500_hw_i2c_xfer()
661 DRM_ERROR("gpio not supported with hw i2c\n"); r500_hw_i2c_xfer()
694 DRM_DEBUG("i2c write error 0x%08x\n", tmp); r500_hw_i2c_xfer()
736 DRM_DEBUG("i2c read error 0x%08x\n", tmp); r500_hw_i2c_xfer()
779 DRM_DEBUG("i2c write error 0x%08x\n", tmp); r500_hw_i2c_xfer()
815 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); radeon_hw_i2c_xfer() local
816 struct radeon_device *rdev = i2c->dev->dev_private; radeon_hw_i2c_xfer()
817 struct radeon_i2c_bus_rec *rec = &i2c->rec; radeon_hw_i2c_xfer()
820 mutex_lock(&i2c->mutex); radeon_hw_i2c_xfer()
846 /* XXX fill in hw i2c implementation */ radeon_hw_i2c_xfer()
863 /* XXX fill in hw i2c implementation */ radeon_hw_i2c_xfer()
873 /* XXX fill in hw i2c implementation */ radeon_hw_i2c_xfer()
880 /* XXX fill in hw i2c implementation */ radeon_hw_i2c_xfer()
883 DRM_ERROR("i2c: unhandled radeon chip\n"); radeon_hw_i2c_xfer()
888 mutex_unlock(&i2c->mutex); radeon_hw_i2c_xfer()
913 struct radeon_i2c_chan *i2c; radeon_i2c_create() local
920 i2c = kzalloc(sizeof(struct radeon_i2c_chan), GFP_KERNEL); radeon_i2c_create()
921 if (i2c == NULL) radeon_i2c_create()
924 i2c->rec = *rec; radeon_i2c_create()
925 i2c->adapter.owner = THIS_MODULE; radeon_i2c_create()
926 i2c->adapter.class = I2C_CLASS_DDC; radeon_i2c_create()
927 i2c->adapter.dev.parent = &dev->pdev->dev; radeon_i2c_create()
928 i2c->dev = dev; radeon_i2c_create()
929 i2c_set_adapdata(&i2c->adapter, i2c); radeon_i2c_create()
930 mutex_init(&i2c->mutex); radeon_i2c_create()
936 /* set the radeon hw i2c adapter */ radeon_i2c_create()
937 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), radeon_i2c_create()
938 "Radeon i2c hw bus %s", name); radeon_i2c_create()
939 i2c->adapter.algo = &radeon_i2c_algo; radeon_i2c_create()
940 ret = i2c_add_adapter(&i2c->adapter); radeon_i2c_create()
942 DRM_ERROR("Failed to register hw i2c %s\n", name); radeon_i2c_create()
948 /* hw i2c using atom */ radeon_i2c_create()
949 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), radeon_i2c_create()
950 "Radeon i2c hw bus %s", name); radeon_i2c_create()
951 i2c->adapter.algo = &radeon_atom_i2c_algo; radeon_i2c_create()
952 ret = i2c_add_adapter(&i2c->adapter); radeon_i2c_create()
954 DRM_ERROR("Failed to register hw i2c %s\n", name); radeon_i2c_create()
959 snprintf(i2c->adapter.name, sizeof(i2c->adapter.name), radeon_i2c_create()
960 "Radeon i2c bit bus %s", name); radeon_i2c_create()
961 i2c->adapter.algo_data = &i2c->bit; radeon_i2c_create()
962 i2c->bit.pre_xfer = pre_xfer; radeon_i2c_create()
963 i2c->bit.post_xfer = post_xfer; radeon_i2c_create()
964 i2c->bit.setsda = set_data; radeon_i2c_create()
965 i2c->bit.setscl = set_clock; radeon_i2c_create()
966 i2c->bit.getsda = get_data; radeon_i2c_create()
967 i2c->bit.getscl = get_clock; radeon_i2c_create()
968 i2c->bit.udelay = 10; radeon_i2c_create()
969 i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ radeon_i2c_create()
970 i2c->bit.data = i2c; radeon_i2c_create()
971 ret = i2c_bit_add_bus(&i2c->adapter); radeon_i2c_create()
973 DRM_ERROR("Failed to register bit i2c %s\n", name); radeon_i2c_create()
978 return i2c; radeon_i2c_create()
980 kfree(i2c); radeon_i2c_create()
985 void radeon_i2c_destroy(struct radeon_i2c_chan *i2c) radeon_i2c_destroy() argument
987 if (!i2c) radeon_i2c_destroy()
989 i2c_del_adapter(&i2c->adapter); radeon_i2c_destroy()
990 if (i2c->has_aux) radeon_i2c_destroy()
991 drm_dp_aux_unregister(&i2c->aux); radeon_i2c_destroy()
992 kfree(i2c); radeon_i2c_destroy()
1080 DRM_DEBUG("i2c 0x%02x 0x%02x read failed\n", radeon_i2c_get_byte()
1102 DRM_DEBUG("i2c 0x%02x 0x%02x write failed\n", radeon_i2c_put_byte()
/linux-4.4.14/drivers/iio/gyro/
H A Ditg3200_buffer.c15 #include <linux/i2c.h>
26 static int itg3200_read_all_channels(struct i2c_client *i2c, __be16 *buf) itg3200_read_all_channels() argument
31 .addr = i2c->addr, itg3200_read_all_channels()
32 .flags = i2c->flags, itg3200_read_all_channels()
37 .addr = i2c->addr, itg3200_read_all_channels()
38 .flags = i2c->flags | I2C_M_RD, itg3200_read_all_channels()
44 return i2c_transfer(i2c->adapter, msg, 2); itg3200_read_all_channels()
54 int ret = itg3200_read_all_channels(st->i2c, buf); itg3200_trigger_handler()
118 ret = request_irq(st->i2c->irq, itg3200_probe_trigger()
127 st->trig->dev.parent = &st->i2c->dev; itg3200_probe_trigger()
140 free_irq(st->i2c->irq, st->trig); itg3200_probe_trigger()
151 free_irq(st->i2c->irq, st->trig); itg3200_remove_trigger()
H A Dbmg160_i2c.c1 #include <linux/i2c.h>
23 dev_err(&client->dev, "Failed to register i2c regmap %d\n", bmg160_i2c_probe()
55 MODULE_DEVICE_TABLE(i2c, bmg160_i2c_id);
H A Dst_gyro_i2c.c14 #include <linux/i2c.h>
98 MODULE_DEVICE_TABLE(i2c, st_gyro_id_table);
102 .name = "st-gyro-i2c",
112 MODULE_DESCRIPTION("STMicroelectronics gyroscopes i2c driver");
/linux-4.4.14/drivers/media/usb/dvb-usb/
H A Ddvb-usb-i2c.c1 /* dvb-usb-i2c.c is part of the DVB USB library.
18 err("no i2c algorithm specified"); dvb_usb_i2c_init()
30 err("could not add i2c adapter"); dvb_usb_i2c_init()
/linux-4.4.14/include/media/blackfin/
H A Dbfin_capture.h4 #include <linux/i2c.h>
24 /* i2c bus adapter no */
26 /* i2c subdevice board info */
/linux-4.4.14/arch/cris/include/asm/
H A Detraxi2c.h12 /* in write operations, the argument contains both i2c
23 #define I2C_WRITEREG 0x1 /* write to an i2c register */
24 #define I2C_READREG 0x2 /* read from an i2c register */
/linux-4.4.14/arch/arm/mach-s3c24xx/
H A Dsetup-i2c.c1 /* linux/arch/arm/plat-s3c24xx/setup-i2c.c
6 * S3C24XX Base setup for i2c device
19 #include <linux/platform_data/i2c-s3c2410.h>
/linux-4.4.14/drivers/staging/iio/meter/
H A DMakefile14 obj-$(CONFIG_ADE7854_I2C) += ade7854-i2c.o
H A Dade7854-i2c.c11 #include <linux/i2c.h>
31 ret = i2c_master_send(st->i2c, st->tx, 3); ade7854_i2c_write_reg_8()
51 ret = i2c_master_send(st->i2c, st->tx, 4); ade7854_i2c_write_reg_16()
72 ret = i2c_master_send(st->i2c, st->tx, 5); ade7854_i2c_write_reg_24()
94 ret = i2c_master_send(st->i2c, st->tx, 6); ade7854_i2c_write_reg_32()
112 ret = i2c_master_send(st->i2c, st->tx, 2); ade7854_i2c_read_reg_8()
116 ret = i2c_master_recv(st->i2c, st->rx, 1); ade7854_i2c_read_reg_8()
138 ret = i2c_master_send(st->i2c, st->tx, 2); ade7854_i2c_read_reg_16()
142 ret = i2c_master_recv(st->i2c, st->rx, 2); ade7854_i2c_read_reg_16()
164 ret = i2c_master_send(st->i2c, st->tx, 2); ade7854_i2c_read_reg_24()
168 ret = i2c_master_recv(st->i2c, st->rx, 3); ade7854_i2c_read_reg_24()
190 ret = i2c_master_send(st->i2c, st->tx, 2); ade7854_i2c_read_reg_32()
194 ret = i2c_master_recv(st->i2c, st->rx, 3); ade7854_i2c_read_reg_32()
224 st->i2c = client; ade7854_i2c_probe()
242 MODULE_DEVICE_TABLE(i2c, ade7854_id);
/linux-4.4.14/drivers/video/fbdev/i810/
H A DMakefile16 i810fb-objs += i810-i2c.o
/linux-4.4.14/drivers/media/usb/go7007/
H A DMakefile6 go7007-y := go7007-v4l2.o go7007-driver.o go7007-i2c.o go7007-fw.o \
/linux-4.4.14/drivers/gpu/drm/nouveau/nvkm/subdev/bios/
H A Di2c.c26 #include <subdev/bios/i2c.h>
31 u16 i2c = 0x0000; dcb_i2c_table() local
35 i2c = nvbios_rd16(bios, dcb + 2); dcb_i2c_table()
37 i2c = nvbios_rd16(bios, dcb + 4); dcb_i2c_table()
40 if (i2c && *ver >= 0x42) { dcb_i2c_table()
45 if (i2c && *ver >= 0x30) { dcb_i2c_table()
46 *ver = nvbios_rd08(bios, i2c + 0); dcb_i2c_table()
47 *hdr = nvbios_rd08(bios, i2c + 1); dcb_i2c_table()
48 *cnt = nvbios_rd08(bios, i2c + 2); dcb_i2c_table()
49 *len = nvbios_rd08(bios, i2c + 3); dcb_i2c_table()
57 return i2c; dcb_i2c_table()
64 u16 i2c = dcb_i2c_table(bios, ver, &hdr, &cnt, len); dcb_i2c_entry() local
65 if (i2c && idx < cnt) dcb_i2c_entry()
66 return i2c + hdr + (idx * *len); dcb_i2c_entry()
130 nvkm_warn(subdev, "unknown i2c type %d\n", info->type); dcb_i2c_parse()
137 /* BMP (from v4.0 has i2c info in the structure, it's in a dcb_i2c_parse()
/linux-4.4.14/drivers/nfc/st-nci/
H A DMakefile8 st-nci_i2c-objs = i2c.o
/linux-4.4.14/drivers/power/
H A Dmax8998_charger.c47 struct i2c_client *i2c = max8998->iodev->i2c; max8998_battery_get_property() local
53 ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg); max8998_battery_get_property()
62 ret = max8998_read_reg(i2c, MAX8998_REG_STATUS2, &reg); max8998_battery_get_property()
91 struct i2c_client *i2c; max8998_battery_probe() local
107 i2c = max8998->iodev->i2c; max8998_battery_probe()
113 max8998_update_reg(i2c, MAX8998_REG_CHGR1, max8998_battery_probe()
126 max8998_update_reg(i2c, MAX8998_REG_CHGR1, 0x1 << 3, 0x3 << 3); max8998_battery_probe()
129 max8998_update_reg(i2c, MAX8998_REG_CHGR1, 0x0 << 3, 0x3 << 3); max8998_battery_probe()
132 max8998_update_reg(i2c, MAX8998_REG_CHGR1, 0x2 << 3, 0x3 << 3); max8998_battery_probe()
135 max8998_update_reg(i2c, MAX8998_REG_CHGR1, 0x3 << 3, 0x3 << 3); max8998_battery_probe()
149 max8998_update_reg(i2c, MAX8998_REG_CHGR2, 0x0 << 4, 0x3 << 4); max8998_battery_probe()
152 max8998_update_reg(i2c, MAX8998_REG_CHGR2, 0x1 << 4, 0x3 << 4); max8998_battery_probe()
155 max8998_update_reg(i2c, MAX8998_REG_CHGR2, 0x2 << 4, 0x3 << 4); max8998_battery_probe()
158 max8998_update_reg(i2c, MAX8998_REG_CHGR2, 0x3 << 4, 0x3 << 4); max8998_battery_probe()
H A Dmax8997_charger.c48 struct i2c_client *i2c = charger->iodev->i2c; max8997_battery_get_property() local
55 ret = max8997_read_reg(i2c, MAX8997_REG_STATUS4, &reg); max8997_battery_get_property()
64 ret = max8997_read_reg(i2c, MAX8997_REG_STATUS4, &reg); max8997_battery_get_property()
73 ret = max8997_read_reg(i2c, MAX8997_REG_STATUS4, &reg); max8997_battery_get_property()
114 ret = max8997_update_reg(iodev->i2c, max8997_battery_probe()
117 dev_err(&pdev->dev, "Cannot use i2c bus.\n"); max8997_battery_probe()
124 ret = max8997_update_reg(iodev->i2c, MAX8997_REG_MBCCTRL1, max8997_battery_probe()
128 ret = max8997_update_reg(iodev->i2c, MAX8997_REG_MBCCTRL1, max8997_battery_probe()
132 ret = max8997_update_reg(iodev->i2c, MAX8997_REG_MBCCTRL1, max8997_battery_probe()
136 ret = max8997_update_reg(iodev->i2c, MAX8997_REG_MBCCTRL1, max8997_battery_probe()
145 dev_err(&pdev->dev, "Cannot use i2c bus.\n"); max8997_battery_probe()
/linux-4.4.14/arch/sh/include/asm/
H A Di2c-sh7760.h8 #define SH7760_I2C_DEVNAME "sh7760-i2c"
/linux-4.4.14/include/linux/i2c/
H A Dds620.h5 #include <linux/i2c.h>
/linux-4.4.14/drivers/regulator/
H A Disl6271a-regulator.c24 #include <linux/i2c.h>
109 static int isl6271a_probe(struct i2c_client *i2c, isl6271a_probe() argument
113 struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); isl6271a_probe()
117 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) isl6271a_probe()
120 pmic = devm_kzalloc(&i2c->dev, sizeof(struct isl_pmic), GFP_KERNEL); isl6271a_probe()
124 pmic->client = i2c; isl6271a_probe()
129 config.dev = &i2c->dev; isl6271a_probe()
136 pmic->rdev[i] = devm_regulator_register(&i2c->dev, &isl_rd[i], isl6271a_probe()
139 dev_err(&i2c->dev, "failed to register %s\n", id->name); isl6271a_probe()
144 i2c_set_clientdata(i2c, pmic); isl6271a_probe()
154 MODULE_DEVICE_TABLE(i2c, isl6271a_id);
H A Dmt6311-regulator.c17 #include <linux/i2c.h>
102 static int mt6311_i2c_probe(struct i2c_client *i2c, mt6311_i2c_probe() argument
111 regmap = devm_regmap_init_i2c(i2c, &mt6311_regmap_config); mt6311_i2c_probe()
114 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", mt6311_i2c_probe()
121 dev_err(&i2c->dev, "Failed to read DEVICE_ID reg: %d\n", ret); mt6311_i2c_probe()
131 dev_err(&i2c->dev, "Unsupported device id = 0x%x.\n", data); mt6311_i2c_probe()
136 config.dev = &i2c->dev; mt6311_i2c_probe()
139 rdev = devm_regulator_register(&i2c->dev, mt6311_i2c_probe()
142 dev_err(&i2c->dev, mt6311_i2c_probe()
155 MODULE_DEVICE_TABLE(i2c, mt6311_i2c_id);
H A Disl9305.c16 #include <linux/i2c.h>
140 static int isl9305_i2c_probe(struct i2c_client *i2c, isl9305_i2c_probe() argument
144 struct isl9305_pdata *pdata = i2c->dev.platform_data; isl9305_i2c_probe()
149 regmap = devm_regmap_init_i2c(i2c, &isl9305_regmap); isl9305_i2c_probe()
152 dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret); isl9305_i2c_probe()
156 config.dev = &i2c->dev; isl9305_i2c_probe()
164 rdev = devm_regulator_register(&i2c->dev, isl9305_i2c_probe()
169 dev_err(&i2c->dev, "Failed to register %s: %d\n", isl9305_i2c_probe()
194 MODULE_DEVICE_TABLE(i2c, isl9305_i2c_id);
H A Dlp3971.c17 #include <linux/i2c.h>
27 struct i2c_client *i2c; member in struct:lp3971
321 static int lp3971_i2c_read(struct i2c_client *i2c, char reg, int count, lp3971_i2c_read() argument
328 ret = i2c_smbus_read_byte_data(i2c, reg); lp3971_i2c_read()
336 static int lp3971_i2c_write(struct i2c_client *i2c, char reg, int count, lp3971_i2c_write() argument
341 return i2c_smbus_write_byte_data(i2c, reg, *src); lp3971_i2c_write()
350 lp3971_i2c_read(lp3971->i2c, reg, 1, &val); lp3971_reg_read()
367 ret = lp3971_i2c_read(lp3971->i2c, reg, 1, &tmp); lp3971_set_bits()
370 ret = lp3971_i2c_write(lp3971->i2c, reg, 1, &tmp); lp3971_set_bits()
407 static int lp3971_i2c_probe(struct i2c_client *i2c, lp3971_i2c_probe() argument
411 struct lp3971_platform_data *pdata = dev_get_platdata(&i2c->dev); lp3971_i2c_probe()
416 dev_dbg(&i2c->dev, "No platform init data supplied\n"); lp3971_i2c_probe()
420 lp3971 = devm_kzalloc(&i2c->dev, sizeof(struct lp3971), GFP_KERNEL); lp3971_i2c_probe()
424 lp3971->i2c = i2c; lp3971_i2c_probe()
425 lp3971->dev = &i2c->dev; lp3971_i2c_probe()
430 ret = lp3971_i2c_read(i2c, LP3971_SYS_CONTROL1_REG, 1, &val); lp3971_i2c_probe()
434 dev_err(&i2c->dev, "failed to detect device\n"); lp3971_i2c_probe()
442 i2c_set_clientdata(i2c, lp3971); lp3971_i2c_probe()
450 MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id);
H A Dda9210-regulator.c22 #include <linux/i2c.h>
177 static int da9210_i2c_probe(struct i2c_client *i2c, da9210_i2c_probe() argument
181 struct device *dev = &i2c->dev; da9210_i2c_probe()
187 chip = devm_kzalloc(&i2c->dev, sizeof(struct da9210), GFP_KERNEL); da9210_i2c_probe()
191 chip->regmap = devm_regmap_init_i2c(i2c, &da9210_regmap_config); da9210_i2c_probe()
194 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", da9210_i2c_probe()
199 config.dev = &i2c->dev; da9210_i2c_probe()
211 dev_err(&i2c->dev, "Failed to write to mask reg: %d\n", error); da9210_i2c_probe()
215 rdev = devm_regulator_register(&i2c->dev, &da9210_reg, &config); da9210_i2c_probe()
217 dev_err(&i2c->dev, "Failed to register DA9210 regulator\n"); da9210_i2c_probe()
222 if (i2c->irq) { da9210_i2c_probe()
223 error = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, da9210_i2c_probe()
229 dev_err(&i2c->dev, "Failed to request IRQ%u: %d\n", da9210_i2c_probe()
230 i2c->irq, error); da9210_i2c_probe()
239 dev_err(&i2c->dev, "Failed to update mask reg: %d\n", da9210_i2c_probe()
244 dev_warn(&i2c->dev, "No IRQ configured\n"); da9210_i2c_probe()
247 i2c_set_clientdata(i2c, chip); da9210_i2c_probe()
257 MODULE_DEVICE_TABLE(i2c, da9210_i2c_id);
H A Dlp3972.c14 #include <linux/i2c.h>
24 struct i2c_client *i2c; member in struct:lp3972
167 static int lp3972_i2c_read(struct i2c_client *i2c, char reg, int count, lp3972_i2c_read() argument
174 ret = i2c_smbus_read_byte_data(i2c, reg); lp3972_i2c_read()
182 static int lp3972_i2c_write(struct i2c_client *i2c, char reg, int count, lp3972_i2c_write() argument
187 return i2c_smbus_write_byte_data(i2c, reg, *src); lp3972_i2c_write()
196 lp3972_i2c_read(lp3972->i2c, reg, 1, &val); lp3972_reg_read()
213 ret = lp3972_i2c_read(lp3972->i2c, reg, 1, &tmp); lp3972_set_bits()
216 ret = lp3972_i2c_write(lp3972->i2c, reg, 1, &tmp); lp3972_set_bits()
502 static int lp3972_i2c_probe(struct i2c_client *i2c, lp3972_i2c_probe() argument
506 struct lp3972_platform_data *pdata = dev_get_platdata(&i2c->dev); lp3972_i2c_probe()
511 dev_dbg(&i2c->dev, "No platform init data supplied\n"); lp3972_i2c_probe()
515 lp3972 = devm_kzalloc(&i2c->dev, sizeof(struct lp3972), GFP_KERNEL); lp3972_i2c_probe()
519 lp3972->i2c = i2c; lp3972_i2c_probe()
520 lp3972->dev = &i2c->dev; lp3972_i2c_probe()
525 ret = lp3972_i2c_read(i2c, LP3972_SYS_CONTROL1_REG, 1, &val); lp3972_i2c_probe()
529 dev_err(&i2c->dev, "chip reported: val = 0x%x\n", val); lp3972_i2c_probe()
532 dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret); lp3972_i2c_probe()
540 i2c_set_clientdata(i2c, lp3972); lp3972_i2c_probe()
548 MODULE_DEVICE_TABLE(i2c, lp3972_i2c_id);
H A Dmax8925-regulator.c15 #include <linux/i2c.h>
30 #define LDO_SEQ_I2C 0x7 /* Power U/D by i2c */
33 #define LDO_I2C_EN 0x1 /* Enable by i2c */
34 #define LDO_I2C_EN_MASK 0x1 /* Enable mask by i2c */
35 #define LDO_I2C_EN_SHIFT 0 /* Enable offset by i2c */
39 struct i2c_client *i2c; member in struct:max8925_regulator_info
51 return max8925_set_bits(info->i2c, info->vol_reg, mask, selector); max8925_set_voltage_sel()
60 ret = max8925_reg_read(info->i2c, info->vol_reg); max8925_get_voltage_sel()
73 return max8925_set_bits(info->i2c, info->enable_reg, max8925_enable()
84 return max8925_set_bits(info->i2c, info->enable_reg, max8925_disable()
95 ret = max8925_reg_read(info->i2c, info->enable_reg); max8925_is_enabled()
117 return max8925_set_bits(info->i2c, info->enable_reg, mask, data); max8925_set_dvm_voltage()
124 return max8925_set_bits(info->i2c, info->vol_reg, 1 << SD1_DVM_EN, max8925_set_dvm_enable()
132 return max8925_set_bits(info->i2c, info->vol_reg, 1 << SD1_DVM_EN, 0); max8925_set_dvm_disable()
304 ri->i2c = chip->i2c; max8925_regulator_probe()
/linux-4.4.14/drivers/media/pci/ivtv/
H A DMakefile3 ivtv-gpio.o ivtv-i2c.o ivtv-ioctl.o ivtv-irq.o \
12 ccflags-y += -I$(srctree)/drivers/media/i2c
/linux-4.4.14/include/linux/iio/common/
H A Dst_sensors_i2c.h2 * STMicroelectronics sensors i2c library driver
14 #include <linux/i2c.h>
/linux-4.4.14/sound/ppc/
H A Dkeywest.c2 * common keywest i2c layer
23 #include <linux/i2c.h>
30 * we have to keep a static variable here since i2c attach_adapter
41 /* If instantiated via i2c-powermac, we still need to set the client */ keywest_probe()
49 * This is kind of a hack, best would be to turn powermac to fixed i2c
81 * Let i2c-core delete that device on driver removal. keywest_attach_adapter()
82 * This is safe because i2c-core holds the core_lock mutex for us. keywest_attach_adapter()
101 { "MAC,tas3004", 0 }, /* instantiated by i2c-powermac */
105 MODULE_DEVICE_TABLE(i2c, keywest_i2c_id);
117 void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c) snd_pmac_keywest_cleanup() argument
119 if (keywest_ctx && keywest_ctx == i2c) { snd_pmac_keywest_cleanup()
140 int snd_pmac_keywest_init(struct pmac_keywest *i2c) snd_pmac_keywest_init() argument
152 keywest_ctx = i2c; snd_pmac_keywest_init()
155 snd_printk(KERN_ERR "cannot register keywest i2c driver\n"); snd_pmac_keywest_init()
160 /* There was already a device from i2c-powermac. Great, let's return */ snd_pmac_keywest_init()
H A Ddaca.c23 #include <linux/i2c.h>
29 /* i2c address */
42 struct pmac_keywest i2c; member in struct:pmac_daca
52 static int daca_init_client(struct pmac_keywest *i2c) daca_init_client() argument
57 if (i2c_smbus_write_byte_data(i2c->client, DACA_REG_SR, 0x08) < 0 || daca_init_client()
58 i2c_smbus_write_byte_data(i2c->client, DACA_REG_GCFG, 0x05) < 0) daca_init_client()
60 return i2c_smbus_write_block_data(i2c->client, DACA_REG_AVOL, daca_init_client()
71 if (! mix->i2c.client) daca_set_volume()
83 if (i2c_smbus_write_block_data(mix->i2c.client, DACA_REG_AVOL, daca_set_volume()
196 i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG, daca_put_amp()
228 i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_SR, 0x08); daca_resume()
229 i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG, daca_resume()
241 snd_pmac_keywest_cleanup(&mix->i2c); daca_cleanup()
252 request_module("i2c-powermac"); snd_pmac_daca_init()
261 mix->i2c.addr = DACA_I2C_ADDR; snd_pmac_daca_init()
262 mix->i2c.init_client = daca_init_client; snd_pmac_daca_init()
263 mix->i2c.name = "DACA"; snd_pmac_daca_init()
264 if ((err = snd_pmac_keywest_init(&mix->i2c)) < 0) snd_pmac_daca_init()
/linux-4.4.14/include/linux/platform_data/
H A Di2c-s3c2410.h43 * @i2c: The platform data to set, or NULL for default data.
56 extern void s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *i2c);
57 extern void s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *i2c);
58 extern void s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *i2c);
59 extern void s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *i2c);
60 extern void s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *i2c);
61 extern void s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *i2c);
62 extern void s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *i2c);
63 extern void s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *i2c);
64 extern void s5p_i2c_hdmiphy_set_platdata(struct s3c2410_platform_i2c *i2c);
H A Di2c-imx.h2 * i2c.h - i.MX I2C driver header file
/linux-4.4.14/arch/powerpc/include/asm/
H A Dpmac_low_i2c.h16 /* i2c mode (based on the platform functions format) */
30 /* i2c bus type */
37 /* i2c bus features */
48 /* i2c busses in the system */
55 /* Lookup an i2c bus for a device-node. The node can be either the bus
62 /* Get the address for an i2c device. This strips the bus number if
75 /* i2c layer adapter helpers */
79 /* March a device or bus with an i2c adapter structure, to be used by drivers
80 * to match device-tree nodes with i2c adapters during adapter discovery
87 /* (legacy) Locking functions exposed to i2c-keywest */
/linux-4.4.14/sound/pci/ice1712/
H A Dews.h53 #define ICE1712_EWX2496_RW 0x08 /* read/write switch for i2c; high = write */
54 #define ICE1712_EWX2496_SERIAL_DATA 0x10 /* i2c & ak4524 data */
55 #define ICE1712_EWX2496_SERIAL_CLOCK 0x20 /* i2c & ak4524 clock */
62 #define ICE1712_EWS88_RW 0x08 /* read/write switch for i2c; high = write */
63 #define ICE1712_EWS88_SERIAL_DATA 0x10 /* i2c & ak4524 data */
64 #define ICE1712_EWS88_SERIAL_CLOCK 0x20 /* i2c & ak4524 clock */
68 /* i2c address */
77 #define ICE1712_6FIRE_RW 0x08 /* read/write switch for i2c; high = write */
78 #define ICE1712_6FIRE_SERIAL_DATA 0x10 /* i2c & ak4524 data */
79 #define ICE1712_6FIRE_SERIAL_CLOCK 0x20 /* i2c & ak4524 clock */
/linux-4.4.14/drivers/spi/
H A Dspi-xcomm.c13 #include <linux/i2c.h>
34 struct i2c_client *i2c; member in struct:spi_xcomm
56 return i2c_master_send(spi_xcomm->i2c, buf, 5); spi_xcomm_sync_config()
120 ret = i2c_master_send(spi_xcomm->i2c, spi_xcomm->buf, t->len + 1); spi_xcomm_txrx_bufs()
126 ret = i2c_master_recv(spi_xcomm->i2c, t->rx_buf, t->len); spi_xcomm_txrx_bufs()
207 static int spi_xcomm_probe(struct i2c_client *i2c, spi_xcomm_probe() argument
214 master = spi_alloc_master(&i2c->dev, sizeof(*spi_xcomm)); spi_xcomm_probe()
219 spi_xcomm->i2c = i2c; spi_xcomm_probe()
226 master->dev.of_node = i2c->dev.of_node; spi_xcomm_probe()
227 i2c_set_clientdata(i2c, master); spi_xcomm_probe()
229 ret = devm_spi_register_master(&i2c->dev, master); spi_xcomm_probe()
240 MODULE_DEVICE_TABLE(i2c, spi_xcomm_ids);
/linux-4.4.14/drivers/iio/common/ms_sensors/
H A Dms_sensors_i2c.h14 #include <linux/i2c.h>
21 * @client: i2c client
22 * @lock: lock protecting the i2c conversion
33 * @client: i2c client
34 * @lock: lock protecting the i2c conversion
/linux-4.4.14/arch/arm/mach-imx/devices/
H A Dplatform-imx-i2c.c26 imx_imx_i2c_data_entry_single(MX1, "imx1-i2c", 0, , SZ_4K);
31 imx_imx_i2c_data_entry_single(MX21, "imx21-i2c", 0, , SZ_4K);
37 imx_imx_i2c_data_entry(MX27, "imx21-i2c", _id, _hwid, SZ_4K)
46 imx_imx_i2c_data_entry(MX31, "imx21-i2c", _id, _hwid, SZ_4K)
56 imx_imx_i2c_data_entry(MX35, "imx21-i2c", _id, _hwid, SZ_4K)
/linux-4.4.14/include/linux/
H A Di2c-dev.h2 i2c-dev.h - i2c-bus driver, char device interface
25 #include <uapi/linux/i2c-dev.h>
H A Di2c-ocores.h2 * i2c-ocores.h - definitions for the i2c-ocores interface
H A Di2c-pca-platform.h8 int i2c_clock_speed; /* values are defined in linux/i2c-algo-pca.h */
/linux-4.4.14/drivers/rtc/
H A Drtc-88pm860x.c27 struct i2c_client *i2c; member in struct:pm860x_rtc_info
66 pm860x_set_bits(info->i2c, PM8607_RTC1, mask | ALARM_EN, mask); rtc_update_handler()
76 pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM_EN, ALARM_EN); pm860x_rtc_alarm_irq_enable()
78 pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM_EN, 0); pm860x_rtc_alarm_irq_enable()
115 pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); pm860x_rtc_read_time()
121 pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); pm860x_rtc_read_time()
147 pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); pm860x_rtc_set_time()
153 pm860x_page_reg_write(info->i2c, REG0_DATA, (base >> 24) & 0xFF); pm860x_rtc_set_time()
154 pm860x_page_reg_write(info->i2c, REG1_DATA, (base >> 16) & 0xFF); pm860x_rtc_set_time()
155 pm860x_page_reg_write(info->i2c, REG2_DATA, (base >> 8) & 0xFF); pm860x_rtc_set_time()
156 pm860x_page_reg_write(info->i2c, REG3_DATA, base & 0xFF); pm860x_rtc_set_time()
170 pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); pm860x_rtc_read_alarm()
175 pm860x_bulk_read(info->i2c, PM8607_RTC_EXPIRE1, 4, buf); pm860x_rtc_read_alarm()
182 ret = pm860x_reg_read(info->i2c, PM8607_RTC1); pm860x_rtc_read_alarm()
196 pm860x_set_bits(info->i2c, PM8607_RTC1, ALARM_EN, 0); pm860x_rtc_set_alarm()
198 pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); pm860x_rtc_set_alarm()
204 pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); pm860x_rtc_set_alarm()
220 pm860x_bulk_write(info->i2c, PM8607_RTC_EXPIRE1, 4, buf); pm860x_rtc_set_alarm()
223 pm860x_set_bits(info->i2c, PM8607_RTC1, mask, mask); pm860x_rtc_set_alarm()
226 pm860x_set_bits(info->i2c, PM8607_RTC1, mask, pm860x_rtc_set_alarm()
251 pm860x_bulk_read(info->i2c, REG_VRTC_MEAS1, 2, buf); calibrate_vrtc_work()
260 sum = pm860x_reg_read(info->i2c, PM8607_RTC_MISC1); calibrate_vrtc_work()
267 pm860x_reg_write(info->i2c, PM8607_RTC_MISC1, data); calibrate_vrtc_work()
273 pm860x_reg_write(info->i2c, PM8607_RTC_MISC1, data); calibrate_vrtc_work()
282 pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0); calibrate_vrtc_work()
333 info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; pm860x_rtc_probe()
347 pm860x_page_reg_write(info->i2c, REG0_ADDR, REG0_DATA); pm860x_rtc_probe()
348 pm860x_page_reg_write(info->i2c, REG1_ADDR, REG1_DATA); pm860x_rtc_probe()
349 pm860x_page_reg_write(info->i2c, REG2_ADDR, REG2_DATA); pm860x_rtc_probe()
350 pm860x_page_reg_write(info->i2c, REG3_ADDR, REG3_DATA); pm860x_rtc_probe()
390 pm860x_set_bits(info->i2c, PM8607_RTC1, RTC1_USE_XO, RTC1_USE_XO); pm860x_rtc_probe()
400 pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, MEAS2_VRTC); pm860x_rtc_probe()
419 pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, 0); pm860x_rtc_remove()
/linux-4.4.14/drivers/macintosh/
H A Dwindfarm_ad7417_sensor.c16 #include <linux/i2c.h>
29 struct i2c_client *i2c; member in struct:wf_ad7417_priv
49 rc = i2c_master_send(pv->i2c, buf, 1); wf_ad7417_temp_get()
52 rc = i2c_master_recv(pv->i2c, buf, 2); wf_ad7417_temp_get()
114 rc = i2c_master_send(pv->i2c, buf, 2); wf_ad7417_adc_get()
123 rc = i2c_master_send(pv->i2c, buf, 1); wf_ad7417_adc_get()
128 rc = i2c_master_recv(pv->i2c, buf, 2); wf_ad7417_adc_get()
136 dev_vdbg(&pv->i2c->dev, "ADC chan %d [%s]" wf_ad7417_adc_get()
144 dev_dbg(&pv->i2c->dev, wf_ad7417_adc_get()
207 i2c_master_send(pv->i2c, buf, 2); wf_ad7417_init_chip()
211 rc = i2c_master_send(pv->i2c, buf, 1); wf_ad7417_init_chip()
213 rc = i2c_master_recv(pv->i2c, buf, 1); wf_ad7417_init_chip()
217 dev_dbg(&pv->i2c->dev, "ADC config reg: %02x\n", wf_ad7417_init_chip()
224 rc = i2c_master_send(pv->i2c, buf, 2); wf_ad7417_init_chip()
228 dev_err(&pv->i2c->dev, "Error reading ADC config\n"); wf_ad7417_init_chip()
271 pv->i2c = client; wf_ad7417_probe()
299 pv->i2c = NULL; wf_ad7417_remove()
314 MODULE_DEVICE_TABLE(i2c, wf_ad7417_id);
H A Dwindfarm_max6690_sensor.c13 #include <linux/i2c.h>
29 struct i2c_client *i2c; member in struct:wf_6690_sensor
40 if (max->i2c == NULL) wf_max6690_get()
44 data = i2c_smbus_read_byte_data(max->i2c, MAX6690_EXTERNAL_TEMP); wf_max6690_get()
97 max->i2c = client; wf_max6690_probe()
112 max->i2c = NULL; wf_max6690_remove()
122 MODULE_DEVICE_TABLE(i2c, wf_max6690_id);
H A Dwindfarm_lm75_sensor.c17 #include <linux/i2c.h>
39 struct i2c_client *i2c; member in struct:wf_lm75_sensor
49 if (lm->i2c == NULL) wf_lm75_get()
54 u8 cfg_new, cfg = (u8)i2c_smbus_read_byte_data(lm->i2c, 1); wf_lm75_get()
63 i2c_smbus_write_byte_data(lm->i2c, 1, cfg_new); wf_lm75_get()
71 data = (s32)le16_to_cpu(i2c_smbus_read_word_data(lm->i2c, 0)); wf_lm75_get()
135 lm->i2c = client; wf_lm75_probe()
150 DBG("wf_lm75: i2c detatch called for %s\n", lm->sens.name); wf_lm75_remove()
153 lm->i2c = NULL; wf_lm75_remove()
166 MODULE_DEVICE_TABLE(i2c, wf_lm75_id);
/linux-4.4.14/drivers/media/usb/pvrusb2/
H A DMakefile5 pvrusb2-objs := pvrusb2-i2c-core.o \
19 ccflags-y += -Idrivers/media/i2c
/linux-4.4.14/drivers/nfc/nfcmrvl/
H A Di2c.c21 #include <linux/i2c.h>
35 struct i2c_client *i2c; member in struct:nfcmrvl_i2c_drv_data
46 ret = i2c_master_recv(drv_data->i2c, (u8 *)&nci_hdr, NCI_CTRL_HDR_SIZE); nfcmrvl_i2c_read()
48 nfc_err(&drv_data->i2c->dev, "cannot read NCI header\n"); nfcmrvl_i2c_read()
53 nfc_err(&drv_data->i2c->dev, "invalid packet payload size\n"); nfcmrvl_i2c_read()
67 ret = i2c_master_recv(drv_data->i2c, nfcmrvl_i2c_read()
72 nfc_err(&drv_data->i2c->dev, nfcmrvl_i2c_read()
103 nfc_err(&drv_data->i2c->dev, "read failed %d\n", ret); nfcmrvl_i2c_int_irq_thread_fn()
107 nfc_err(&drv_data->i2c->dev, "corrupted RX packet\n"); nfcmrvl_i2c_int_irq_thread_fn()
137 ret = i2c_master_send(drv_data->i2c, skb->data, skb->len); nfcmrvl_i2c_nci_send()
143 ret = i2c_master_send(drv_data->i2c, skb->data, skb->len); nfcmrvl_i2c_nci_send()
183 if (of_find_property(node, "i2c-int-falling", NULL)) nfcmrvl_i2c_parse_dt()
215 drv_data->i2c = client; nfcmrvl_i2c_probe()
231 ret = devm_request_threaded_irq(&drv_data->i2c->dev, pdata->irq, nfcmrvl_i2c_probe()
236 nfc_err(&drv_data->i2c->dev, nfcmrvl_i2c_probe()
243 &drv_data->i2c->dev, pdata); nfcmrvl_i2c_probe()
264 { .compatible = "marvell,nfc-i2c", },
273 MODULE_DEVICE_TABLE(i2c, nfcmrvl_i2c_id_table);
/linux-4.4.14/drivers/staging/iio/magnetometer/
H A Dhmc5843_i2c.c2 * i2c driver for hmc5843/5843/5883/5883l/5983
14 #include <linux/i2c.h>
79 MODULE_DEVICE_TABLE(i2c, hmc5843_id);
103 MODULE_DESCRIPTION("HMC5843/5883/5883L/5983 i2c driver");
/linux-4.4.14/drivers/iio/accel/
H A Dst_accel_i2c.c14 #include <linux/i2c.h>
126 MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
130 .name = "st-accel-i2c",
140 MODULE_DESCRIPTION("STMicroelectronics accelerometers i2c driver");
/linux-4.4.14/drivers/iio/magnetometer/
H A Dst_magn_i2c.c14 #include <linux/i2c.h>
89 MODULE_DEVICE_TABLE(i2c, st_magn_id_table);
93 .name = "st-magn-i2c",
103 MODULE_DESCRIPTION("STMicroelectronics magnetometers i2c driver");
/linux-4.4.14/drivers/iio/pressure/
H A Dst_pressure_i2c.c14 #include <linux/i2c.h>
78 MODULE_DEVICE_TABLE(i2c, st_press_id_table);
82 .name = "st-press-i2c",
92 MODULE_DESCRIPTION("STMicroelectronics pressures i2c driver");
/linux-4.4.14/drivers/media/pci/ngene/
H A DMakefile5 ngene-objs := ngene-core.o ngene-i2c.o ngene-cards.o ngene-dvb.o
/linux-4.4.14/drivers/media/platform/exynos4-is/
H A Dfimc-is-i2c.h12 #define FIMC_IS_I2C_COMPATIBLE "samsung,exynos4212-i2c-isp"
/linux-4.4.14/drivers/media/usb/au0828/
H A DMakefile1 au0828-objs := au0828-core.o au0828-i2c.o au0828-cards.o au0828-dvb.o
/linux-4.4.14/arch/mips/ath79/
H A Dmach-pb44.c13 #include <linux/i2c.h>
14 #include <linux/i2c-gpio.h>
15 #include <linux/i2c/pcf857x.h>
42 .name = "i2c-gpio",
/linux-4.4.14/arch/arm/mach-omap1/
H A DMakefile22 i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
23 obj-y += $(i2c-omap-m) $(i2c-omap-y)
/linux-4.4.14/include/linux/input/
H A Dtps6507x-ts.h1 /* linux/i2c/tps6507x-ts.h
/linux-4.4.14/drivers/video/backlight/
H A Dtosa_bl.c17 #include <linux/i2c.h>
33 struct i2c_client *i2c; member in struct:tosa_bl_data
41 struct spi_device *spi = dev_get_platdata(&data->i2c->dev); tosa_bl_set_backlight()
43 i2c_smbus_write_byte_data(data->i2c, DAC_CH1, data->comadj); tosa_bl_set_backlight()
46 i2c_smbus_write_byte_data(data->i2c, DAC_CH2, (u8)(brightness & 0xff)); tosa_bl_set_backlight()
103 data->i2c = client; tosa_bl_probe()
161 MODULE_DEVICE_TABLE(i2c, tosa_bl_id);
/linux-4.4.14/drivers/iio/adc/
H A Dti-adc081c.c10 #include <linux/i2c.h>
18 struct i2c_client *i2c; member in struct:adc081c
33 err = i2c_smbus_read_word_swapped(adc->i2c, REG_CONV_RES); adc081c_read_raw()
83 adc->i2c = client; adc081c_probe()
130 MODULE_DEVICE_TABLE(i2c, adc081c_id);

Completed in 8904 milliseconds

1234567891011>>