Lines Matching +full:cros +full:- +full:ec +full:- +full:spi
1 // SPDX-License-Identifier: GPL-2.0-only
5 * This driver provides the ability to control GPIOs on the Chrome OS EC.
23 /* Prefix all names to avoid collisions with EC <-> AP nets */
24 static const char cros_ec_gpio_prefix[] = "EC:";
29 const char *name = gc->names[gpio] + strlen(cros_ec_gpio_prefix);
46 const char *name = gc->names[gpio] + strlen(cros_ec_gpio_prefix);
55 return -EINVAL;
60 dev_err(gc->parent, "error getting gpio%d (%s) on EC: %d\n", gpio, name, ret);
72 const char *name = gc->names[gpio] + strlen(cros_ec_gpio_prefix);
84 dev_err(gc->parent, "error getting direction of gpio%d (%s) on EC: %d\n", gpio, name, ret);
94 return -EINVAL;
97 /* Query EC for all gpio line names */
105 /* EC may not NUL terminate */
111 names = devm_kcalloc(gc->parent, gc->ngpio, sizeof(*names), GFP_KERNEL);
113 return -ENOMEM;
114 gc->names = names;
116 str = devm_kcalloc(gc->parent, gc->ngpio, name_len, GFP_KERNEL);
118 return -ENOMEM;
121 for (i = 0; i < gc->ngpio; i++) {
126 dev_err_probe(gc->parent, ret, "error getting gpio%d info\n", i);
142 /* Query EC for number of gpios */
161 struct device *dev = &pdev->dev;
162 struct device *parent = dev->parent;
164 struct cros_ec_device *cros_ec = ec_dev->ec_dev;
169 /* Use the fwnode from the protocol device, e.g. cros-ec-spi */
170 device_set_node(dev, dev_fwnode(cros_ec->dev));
180 return -ENOMEM;
182 gc->ngpio = ngpios;
183 gc->parent = dev;
188 gc->can_sleep = true;
189 gc->label = dev_name(dev);
190 gc->base = -1;
191 gc->set_rv = cros_ec_gpio_set;
192 gc->get = cros_ec_gpio_get;
193 gc->get_direction = cros_ec_gpio_get_direction;
199 { "cros-ec-gpio", 0 },
207 .name = "cros-ec-gpio",
213 MODULE_DESCRIPTION("ChromeOS EC GPIO Driver");