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()
44 dev_err(gc->parent, "error setting gpio%d (%s) on EC: %d\n", gpio, name, ret); in cros_ec_gpio_set()
49 const char *name = gc->names[gpio] + strlen(cros_ec_gpio_prefix); in cros_ec_gpio_get()
58 return -EINVAL; in cros_ec_gpio_get()
63 dev_err(gc->parent, "error getting gpio%d (%s) on EC: %d\n", gpio, name, ret); in cros_ec_gpio_get()
75 const char *name = gc->names[gpio] + strlen(cros_ec_gpio_prefix); in cros_ec_gpio_get_direction()
87 dev_err(gc->parent, "error getting direction of gpio%d (%s) on EC: %d\n", gpio, name, ret); in cros_ec_gpio_get_direction()
97 return -EINVAL; in cros_ec_gpio_get_direction()
100 /* Query EC for all gpio line names */
108 /* EC may not NUL terminate */ in cros_ec_gpio_init_names()
114 names = devm_kcalloc(gc->parent, gc->ngpio, sizeof(*names), GFP_KERNEL); in cros_ec_gpio_init_names()
116 return -ENOMEM; in cros_ec_gpio_init_names()
117 gc->names = names; in cros_ec_gpio_init_names()
119 str = devm_kcalloc(gc->parent, gc->ngpio, name_len, GFP_KERNEL); in cros_ec_gpio_init_names()
121 return -ENOMEM; in cros_ec_gpio_init_names()
124 for (i = 0; i < gc->ngpio; i++) { in cros_ec_gpio_init_names()
129 dev_err_probe(gc->parent, ret, "error getting gpio%d info\n", i); in cros_ec_gpio_init_names()
145 /* Query EC for number of gpios */
164 struct device *dev = &pdev->dev; in cros_ec_gpio_probe()
165 struct device *parent = dev->parent; in cros_ec_gpio_probe()
167 struct cros_ec_device *cros_ec = ec_dev->ec_dev; in cros_ec_gpio_probe()
172 /* Use the fwnode from the protocol device, e.g. cros-ec-spi */ in cros_ec_gpio_probe()
173 device_set_node(dev, dev_fwnode(cros_ec->dev)); in cros_ec_gpio_probe()
183 return -ENOMEM; in cros_ec_gpio_probe()
185 gc->ngpio = ngpios; in cros_ec_gpio_probe()
186 gc->parent = dev; in cros_ec_gpio_probe()
191 gc->can_sleep = true; in cros_ec_gpio_probe()
192 gc->label = dev_name(dev); in cros_ec_gpio_probe()
193 gc->base = -1; in cros_ec_gpio_probe()
194 gc->set = cros_ec_gpio_set; in cros_ec_gpio_probe()
195 gc->get = cros_ec_gpio_get; in cros_ec_gpio_probe()
196 gc->get_direction = cros_ec_gpio_get_direction; in cros_ec_gpio_probe()
202 { "cros-ec-gpio", 0 },
210 .name = "cros-ec-gpio",
216 MODULE_DESCRIPTION("ChromeOS EC GPIO Driver");