Lines Matching +full:setup +full:- +full:duration +full:- +full:ns
1 // SPDX-License-Identifier: GPL-2.0
10 * CLK0 ----------------------. ,--------.
11 * CLK1 -------------------. `--------|> #0 |
13 * OUT0 ----------------+--|-----------|D0 Q0|-----|<
14 * OUT1 --------------+-|--|-----------|D1 Q1|-----|<
15 * OUT2 ------------+-|-|--|-----------|D2 Q2|-----|<
16 * OUT3 ----------+-|-|-|--|-----------|D3 Q3|-----|<
17 * OUT4 --------+-|-|-|-|--|-----------|D4 Q4|-----|<
18 * OUT5 ------+-|-|-|-|-|--|-----------|D5 Q5|-----|<
19 * OUT6 ----+-|-|-|-|-|-|--|-----------|D6 Q6|-----|<
20 * OUT7 --+-|-|-|-|-|-|-|--|-----------|D7 Q7|-----|<
21 * | | | | | | | | | `--------'
23 * | | | | | | | | | ,--------.
24 * | | | | | | | | `-----------|> #1 |
26 * | | | | | | | `--------------|D0 Q0|-----|<
27 * | | | | | | `----------------|D1 Q1|-----|<
28 * | | | | | `------------------|D2 Q2|-----|<
29 * | | | | `--------------------|D3 Q3|-----|<
30 * | | | `----------------------|D4 Q4|-----|<
31 * | | `------------------------|D5 Q5|-----|<
32 * | `--------------------------|D6 Q6|-----|<
33 * `----------------------------|D7 Q7|-----|<
34 * `--------'
78 int latch = offset / priv->n_latched_gpios; in gpio_latch_set_unlocked()
81 assign_bit(offset, priv->shadow, val); in gpio_latch_set_unlocked()
83 for (i = 0; i < priv->n_latched_gpios; i++) in gpio_latch_set_unlocked()
84 set(priv->latched_gpios->desc[i], in gpio_latch_set_unlocked()
85 test_bit(latch * priv->n_latched_gpios + i, priv->shadow)); in gpio_latch_set_unlocked()
87 ndelay(priv->setup_duration_ns); in gpio_latch_set_unlocked()
88 set(priv->clk_gpios->desc[latch], 1); in gpio_latch_set_unlocked()
89 ndelay(priv->clock_duration_ns); in gpio_latch_set_unlocked()
90 set(priv->clk_gpios->desc[latch], 0); in gpio_latch_set_unlocked()
98 spin_lock_irqsave(&priv->spinlock, flags); in gpio_latch_set()
102 spin_unlock_irqrestore(&priv->spinlock, flags); in gpio_latch_set()
109 mutex_lock(&priv->mutex); in gpio_latch_set_can_sleep()
113 mutex_unlock(&priv->mutex); in gpio_latch_set_can_sleep()
121 if (gpiod_cansleep(priv->clk_gpios->desc[i])) in gpio_latch_can_sleep()
124 for (i = 0; i < priv->n_latched_gpios; i++) in gpio_latch_can_sleep()
125 if (gpiod_cansleep(priv->latched_gpios->desc[i])) in gpio_latch_can_sleep()
143 struct device_node *np = pdev->dev.of_node; in gpio_latch_probe()
145 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in gpio_latch_probe()
147 return -ENOMEM; in gpio_latch_probe()
149 priv->clk_gpios = devm_gpiod_get_array(&pdev->dev, "clk", GPIOD_OUT_LOW); in gpio_latch_probe()
150 if (IS_ERR(priv->clk_gpios)) in gpio_latch_probe()
151 return PTR_ERR(priv->clk_gpios); in gpio_latch_probe()
153 priv->latched_gpios = devm_gpiod_get_array(&pdev->dev, "latched", GPIOD_OUT_LOW); in gpio_latch_probe()
154 if (IS_ERR(priv->latched_gpios)) in gpio_latch_probe()
155 return PTR_ERR(priv->latched_gpios); in gpio_latch_probe()
157 n_latches = priv->clk_gpios->ndescs; in gpio_latch_probe()
158 priv->n_latched_gpios = priv->latched_gpios->ndescs; in gpio_latch_probe()
160 priv->shadow = devm_bitmap_zalloc(&pdev->dev, n_latches * priv->n_latched_gpios, in gpio_latch_probe()
162 if (!priv->shadow) in gpio_latch_probe()
163 return -ENOMEM; in gpio_latch_probe()
166 priv->gc.can_sleep = true; in gpio_latch_probe()
167 priv->gc.set = gpio_latch_set_can_sleep; in gpio_latch_probe()
168 mutex_init(&priv->mutex); in gpio_latch_probe()
170 priv->gc.can_sleep = false; in gpio_latch_probe()
171 priv->gc.set = gpio_latch_set; in gpio_latch_probe()
172 spin_lock_init(&priv->spinlock); in gpio_latch_probe()
175 of_property_read_u32(np, "setup-duration-ns", &priv->setup_duration_ns); in gpio_latch_probe()
176 if (priv->setup_duration_ns > DURATION_NS_MAX) { in gpio_latch_probe()
177 dev_warn(&pdev->dev, "setup-duration-ns too high, limit to %d\n", in gpio_latch_probe()
179 priv->setup_duration_ns = DURATION_NS_MAX; in gpio_latch_probe()
182 of_property_read_u32(np, "clock-duration-ns", &priv->clock_duration_ns); in gpio_latch_probe()
183 if (priv->clock_duration_ns > DURATION_NS_MAX) { in gpio_latch_probe()
184 dev_warn(&pdev->dev, "clock-duration-ns too high, limit to %d\n", in gpio_latch_probe()
186 priv->clock_duration_ns = DURATION_NS_MAX; in gpio_latch_probe()
189 priv->gc.get_direction = gpio_latch_get_direction; in gpio_latch_probe()
190 priv->gc.ngpio = n_latches * priv->n_latched_gpios; in gpio_latch_probe()
191 priv->gc.owner = THIS_MODULE; in gpio_latch_probe()
192 priv->gc.base = -1; in gpio_latch_probe()
193 priv->gc.parent = &pdev->dev; in gpio_latch_probe()
197 return devm_gpiochip_add_data(&pdev->dev, &priv->gc, priv); in gpio_latch_probe()
202 .compatible = "gpio-latch",
210 .name = "gpio-latch",