Lines Matching +full:cros +full:- +full:ec
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); in cros_ec_gpio_set()
46 const char *name = gc->names[gpio] + strlen(cros_ec_gpio_prefix); in cros_ec_gpio_get()
55 return -EINVAL; in cros_ec_gpio_get()
60 dev_err(gc->parent, "error getting gpio%d (%s) on EC: %d\n", gpio, name, ret); in cros_ec_gpio_get()
72 const char *name = gc->names[gpio] + strlen(cros_ec_gpio_prefix); in cros_ec_gpio_get_direction()
84 dev_err(gc->parent, "error getting direction of gpio%d (%s) on EC: %d\n", gpio, name, ret); in cros_ec_gpio_get_direction()
94 return -EINVAL; in cros_ec_gpio_get_direction()
97 /* Query EC for all gpio line names */
105 /* EC may not NUL terminate */ in cros_ec_gpio_init_names()
111 names = devm_kcalloc(gc->parent, gc->ngpio, sizeof(*names), GFP_KERNEL); in cros_ec_gpio_init_names()
113 return -ENOMEM; in cros_ec_gpio_init_names()
114 gc->names = names; in cros_ec_gpio_init_names()
116 str = devm_kcalloc(gc->parent, gc->ngpio, name_len, GFP_KERNEL); in cros_ec_gpio_init_names()
118 return -ENOMEM; in cros_ec_gpio_init_names()
121 for (i = 0; i < gc->ngpio; i++) { in cros_ec_gpio_init_names()
126 dev_err_probe(gc->parent, ret, "error getting gpio%d info\n", i); in cros_ec_gpio_init_names()
142 /* Query EC for number of gpios */
161 struct device *dev = &pdev->dev; in cros_ec_gpio_probe()
162 struct device *parent = dev->parent; in cros_ec_gpio_probe()
164 struct cros_ec_device *cros_ec = ec_dev->ec_dev; in cros_ec_gpio_probe()
169 /* Use the fwnode from the protocol device, e.g. cros-ec-spi */ in cros_ec_gpio_probe()
170 device_set_node(dev, dev_fwnode(cros_ec->dev)); in cros_ec_gpio_probe()
180 return -ENOMEM; in cros_ec_gpio_probe()
182 gc->ngpio = ngpios; in cros_ec_gpio_probe()
183 gc->parent = dev; in cros_ec_gpio_probe()
188 gc->can_sleep = true; in cros_ec_gpio_probe()
189 gc->label = dev_name(dev); in cros_ec_gpio_probe()
190 gc->base = -1; in cros_ec_gpio_probe()
191 gc->set = cros_ec_gpio_set; in cros_ec_gpio_probe()
192 gc->get = cros_ec_gpio_get; in cros_ec_gpio_probe()
193 gc->get_direction = cros_ec_gpio_get_direction; in cros_ec_gpio_probe()
199 { "cros-ec-gpio", 0 },
207 .name = "cros-ec-gpio",
213 MODULE_DESCRIPTION("ChromeOS EC GPIO Driver");