Lines Matching refs:desc

32 static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)  in gpio_to_device()  argument
44 desc->dev = dev; in gpio_to_device()
45 desc->offset = gpio - uc_priv->gpio_base; in gpio_to_device()
46 desc->flags = 0; in gpio_to_device()
55 int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc) in dm_gpio_lookup_name() argument
88 desc->dev = dev; in dm_gpio_lookup_name()
89 desc->offset = offset; in dm_gpio_lookup_name()
97 struct gpio_desc desc; in gpio_lookup_name() local
102 ret = dm_gpio_lookup_name(name, &desc); in gpio_lookup_name()
107 *devp = desc.dev; in gpio_lookup_name()
109 *offsetp = desc.offset; in gpio_lookup_name()
111 struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(desc.dev); in gpio_lookup_name()
113 *gpiop = uc_priv->gpio_base + desc.offset; in gpio_lookup_name()
119 int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc, in gpio_xlate_offs_flags() argument
125 desc->offset = args->args[0]; in gpio_xlate_offs_flags()
131 desc->flags = GPIOD_ACTIVE_LOW; in gpio_xlate_offs_flags()
136 static int gpio_find_and_xlate(struct gpio_desc *desc, in gpio_find_and_xlate() argument
139 struct dm_gpio_ops *ops = gpio_get_ops(desc->dev); in gpio_find_and_xlate()
142 return ops->xlate(desc->dev, desc, args); in gpio_find_and_xlate()
144 return gpio_xlate_offs_flags(desc->dev, desc, args); in gpio_find_and_xlate()
239 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc) in gpio_hog_lookup_name() argument
243 *desc = NULL; in gpio_hog_lookup_name()
248 *desc = &priv->gpiod; in gpio_hog_lookup_name()
264 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc) in gpio_hog_lookup_name() argument
270 int dm_gpio_request(struct gpio_desc *desc, const char *label) in dm_gpio_request() argument
272 struct udevice *dev = desc->dev; in dm_gpio_request()
278 if (uc_priv->name[desc->offset]) in dm_gpio_request()
284 ret = gpio_get_ops(dev)->request(dev, desc->offset, label); in dm_gpio_request()
290 uc_priv->name[desc->offset] = str; in dm_gpio_request()
295 static int dm_gpio_requestf(struct gpio_desc *desc, const char *fmt, ...) in dm_gpio_requestf() argument
304 return dm_gpio_request(desc, buf); in dm_gpio_requestf()
306 return dm_gpio_request(desc, fmt); in dm_gpio_requestf()
324 struct gpio_desc desc; in gpio_request() local
327 ret = gpio_to_device(gpio, &desc); in gpio_request()
331 return dm_gpio_request(&desc, label); in gpio_request()
389 struct gpio_desc desc; in gpio_free() local
392 ret = gpio_to_device(gpio, &desc); in gpio_free()
396 return _dm_gpio_free(desc.dev, desc.offset); in gpio_free()
399 static int check_reserved(const struct gpio_desc *desc, const char *func) in check_reserved() argument
403 if (!dm_gpio_is_valid(desc)) in check_reserved()
406 uc_priv = dev_get_uclass_priv(desc->dev); in check_reserved()
407 if (!uc_priv->name[desc->offset]) { in check_reserved()
409 desc->dev->name, func, in check_reserved()
411 desc->offset); in check_reserved()
428 struct gpio_desc desc; in gpio_direction_input() local
431 ret = gpio_to_device(gpio, &desc); in gpio_direction_input()
434 ret = check_reserved(&desc, "dir_input"); in gpio_direction_input()
438 return gpio_get_ops(desc.dev)->direction_input(desc.dev, desc.offset); in gpio_direction_input()
452 struct gpio_desc desc; in gpio_direction_output() local
455 ret = gpio_to_device(gpio, &desc); in gpio_direction_output()
458 ret = check_reserved(&desc, "dir_output"); in gpio_direction_output()
462 return gpio_get_ops(desc.dev)->direction_output(desc.dev, in gpio_direction_output()
463 desc.offset, value); in gpio_direction_output()
466 int dm_gpio_get_value(const struct gpio_desc *desc) in dm_gpio_get_value() argument
471 ret = check_reserved(desc, "get_value"); in dm_gpio_get_value()
475 value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset); in dm_gpio_get_value()
477 return desc->flags & GPIOD_ACTIVE_LOW ? !value : value; in dm_gpio_get_value()
480 int dm_gpio_set_value(const struct gpio_desc *desc, int value) in dm_gpio_set_value() argument
484 ret = check_reserved(desc, "set_value"); in dm_gpio_set_value()
488 if (desc->flags & GPIOD_ACTIVE_LOW) in dm_gpio_set_value()
490 gpio_get_ops(desc->dev)->set_value(desc->dev, desc->offset, value); in dm_gpio_set_value()
494 int dm_gpio_get_open_drain(struct gpio_desc *desc) in dm_gpio_get_open_drain() argument
496 struct dm_gpio_ops *ops = gpio_get_ops(desc->dev); in dm_gpio_get_open_drain()
499 ret = check_reserved(desc, "get_open_drain"); in dm_gpio_get_open_drain()
504 return ops->get_open_drain(desc->dev, desc->offset); in dm_gpio_get_open_drain()
509 int dm_gpio_set_open_drain(struct gpio_desc *desc, int value) in dm_gpio_set_open_drain() argument
511 struct dm_gpio_ops *ops = gpio_get_ops(desc->dev); in dm_gpio_set_open_drain()
514 ret = check_reserved(desc, "set_open_drain"); in dm_gpio_set_open_drain()
519 ret = ops->set_open_drain(desc->dev, desc->offset, value); in dm_gpio_set_open_drain()
526 int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags) in dm_gpio_set_dir_flags() argument
528 struct udevice *dev = desc->dev; in dm_gpio_set_dir_flags()
532 ret = check_reserved(desc, "set_dir"); in dm_gpio_set_dir_flags()
541 ret = ops->direction_output(dev, desc->offset, value); in dm_gpio_set_dir_flags()
543 ret = ops->direction_input(dev, desc->offset); in dm_gpio_set_dir_flags()
551 desc->flags = flags; in dm_gpio_set_dir_flags()
556 int dm_gpio_set_dir(struct gpio_desc *desc) in dm_gpio_set_dir() argument
558 return dm_gpio_set_dir_flags(desc, desc->flags); in dm_gpio_set_dir()
574 struct gpio_desc desc; in gpio_get_value() local
576 ret = gpio_to_device(gpio, &desc); in gpio_get_value()
579 return dm_gpio_get_value(&desc); in gpio_get_value()
593 struct gpio_desc desc; in gpio_set_value() local
596 ret = gpio_to_device(gpio, &desc); in gpio_set_value()
599 return dm_gpio_set_value(&desc, value); in gpio_set_value()
804 struct gpio_desc *desc, int flags, in gpio_request_tail() argument
807 desc->dev = gpio_dev; in gpio_request_tail()
808 desc->offset = 0; in gpio_request_tail()
809 desc->flags = 0; in gpio_request_tail()
813 if (!desc->dev) { in gpio_request_tail()
815 &desc->dev); in gpio_request_tail()
822 ret = gpio_find_and_xlate(desc, args); in gpio_request_tail()
827 ret = dm_gpio_requestf(desc, add_index ? "%s.%s%d" : "%s.%s", in gpio_request_tail()
833 ret = dm_gpio_set_dir_flags(desc, flags | desc->flags); in gpio_request_tail()
847 int index, struct gpio_desc *desc, in _gpio_request_by_name_nodev() argument
857 index, desc, flags, add_index, NULL); in _gpio_request_by_name_nodev()
861 struct gpio_desc *desc, int flags) in gpio_request_by_name_nodev() argument
863 return _gpio_request_by_name_nodev(node, list_name, index, desc, flags, in gpio_request_by_name_nodev()
868 struct gpio_desc *desc, int flags) in gpio_request_by_name() argument
878 index, desc, flags, index > 0, NULL); in gpio_request_by_name()
882 struct gpio_desc *desc, int max_count, in gpio_request_list_by_name_nodev() argument
890 &desc[count], flags, true); in gpio_request_list_by_name_nodev()
901 gpio_free_list_nodev(desc, count - 1); in gpio_request_list_by_name_nodev()
907 struct gpio_desc *desc, int max_count, in gpio_request_list_by_name() argument
915 return gpio_request_list_by_name_nodev(dev_ofnode(dev), list_name, desc, in gpio_request_list_by_name()
934 int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc) in dm_gpio_free() argument
937 return _dm_gpio_free(desc->dev, desc->offset); in dm_gpio_free()
940 int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count) in gpio_free_list() argument
946 dm_gpio_free(dev, &desc[i]); in gpio_free_list()
951 int gpio_free_list_nodev(struct gpio_desc *desc, int count) in gpio_free_list_nodev() argument
953 return gpio_free_list(NULL, desc, count); in gpio_free_list_nodev()
982 int gpio_get_number(const struct gpio_desc *desc) in gpio_get_number() argument
984 struct udevice *dev = desc->dev; in gpio_get_number()
991 return uc_priv->gpio_base + desc->offset; in gpio_get_number()
1021 int dtflags, struct gpio_desc *desc) in gpio_dev_request_index() argument
1030 return gpio_request_tail(0, nodename, &args, list_name, index, desc, in gpio_dev_request_index()