Lines Matching defs:host
38 spinlock_t lock; /* host lock */
47 * @host: the host we're using
50 static void cbus_send_bit(struct cbus_host *host, unsigned bit)
52 gpiod_set_value(host->dat, bit ? 1 : 0);
53 gpiod_set_value(host->clk, 1);
54 gpiod_set_value(host->clk, 0);
59 * @host: the host we're using
63 static void cbus_send_data(struct cbus_host *host, unsigned data, unsigned len)
68 cbus_send_bit(host, data & (1 << (i - 1)));
73 * @host: the host we're using
75 static int cbus_receive_bit(struct cbus_host *host)
79 gpiod_set_value(host->clk, 1);
80 ret = gpiod_get_value(host->dat);
81 gpiod_set_value(host->clk, 0);
87 * @host: the host we're using
89 static int cbus_receive_word(struct cbus_host *host)
95 int bit = cbus_receive_bit(host);
108 * @host: the host we're using
114 static int cbus_transfer(struct cbus_host *host, char rw, unsigned dev,
121 spin_lock_irqsave(&host->lock, flags);
124 gpiod_set_value(host->sel, 0);
127 gpiod_direction_output(host->dat, 1);
130 cbus_send_data(host, dev, CBUS_ADDR_BITS);
133 cbus_send_bit(host, rw == I2C_SMBUS_READ);
136 cbus_send_data(host, reg, CBUS_REG_BITS);
139 cbus_send_data(host, data, 16);
142 ret = gpiod_direction_input(host->dat);
144 dev_dbg(host->dev, "failed setting direction\n");
147 gpiod_set_value(host->clk, 1);
149 ret = cbus_receive_word(host);
151 dev_dbg(host->dev, "failed receiving data\n");
157 gpiod_set_value(host->sel, 1);
158 gpiod_set_value(host->clk, 1);
159 gpiod_set_value(host->clk, 0);
162 spin_unlock_irqrestore(&host->lock, flags);