From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Herrmann Date: Wed, 29 Aug 2012 14:00:27 +0200 Subject: [U-Boot] [PATCH 5/7] dm: gpio: Add draft GPIO core and convert sandbox to use it In-Reply-To: <1345564853-24500-6-git-send-email-marex@denx.de> References: <1345564853-24500-1-git-send-email-marex@denx.de> <1345564853-24500-6-git-send-email-marex@denx.de> Message-ID: <39609285.ETq8Rsx0ta@merom> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi On Tuesday 21 August 2012 18:00:51 Marek Vasut wrote: ...snip... > +/** > + * gpio_request() - [COMPAT] Request GPIO > + * gpio: GPIO number > + * label: Name for the requested GPIO > + * > + * This function implements the API that's compatible with current > + * GPIO API used in U-Boot. The request is forwarded to particular > + * GPIO driver. Returns 0 on success, negative value on error. > + */ > +int gpio_request(unsigned gpio, const char *label) > +{ > + struct gpio_core_entry *e = gpio_to_entry(gpio); > + if (!e) > + return -EINVAL; > + > + return e->ops->gpio_request(gpio, label); > +} ...snip... Your core should have a driver API (as described in the core document), which should be in form of gpio_$fname for each $fname in the gpio_ops. on top of those you can have the command API, which accesses the gpio pins in a linear fashion (like what you have now) the reason for this is if you have a device on gpio (say some LEDs), which knows (from platform data) that pins 3-6 of the parent device are connected to this device. in your API, this has no way of working - even if you put global pin numbering in the platform data, this would stop working if you had a PnP GPIO controllers (say USB). regards Pavel Herrmann