Skip to content

Commit

Permalink
gpio: rockchip: Switch to use fwnode instead of of_node
Browse files Browse the repository at this point in the history
GPIO library now accepts fwnode as a firmware node, so
switch the driver to use it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  • Loading branch information
andy-shev authored and intel-lab-lkp committed Aug 30, 2022
1 parent 583fa77 commit 678cf64
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
32 changes: 17 additions & 15 deletions drivers/gpio/gpio-rockchip.c
Expand Up @@ -20,6 +20,7 @@
#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/property.h>
#include <linux/regmap.h>

#include "../pinctrl/core.h"
Expand Down Expand Up @@ -518,7 +519,7 @@ static int rockchip_interrupts_register(struct rockchip_pin_bank *bank)
struct irq_chip_generic *gc;
int ret;

bank->domain = irq_domain_add_linear(bank->of_node, 32,
bank->domain = irq_domain_create_linear(bank->fwnode, 32,
&irq_generic_chip_ops, NULL);
if (!bank->domain) {
dev_warn(bank->dev, "could not init irq domain for bank %s\n",
Expand Down Expand Up @@ -606,14 +607,14 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
* files which don't set the "gpio-ranges" property or systems that
* utilize ACPI the driver has to call gpiochip_add_pin_range().
*/
if (!of_property_read_bool(bank->of_node, "gpio-ranges")) {
struct device_node *pctlnp = of_get_parent(bank->of_node);
if (!fwnode_property_read_bool(bank->fwnode, "gpio-ranges")) {
struct fwnode_handle *parent = fwnode_get_parent(bank->fwnode);
struct pinctrl_dev *pctldev = NULL;

if (!pctlnp)
return -ENODATA;

pctldev = of_pinctrl_get(pctlnp);
pctldev = of_pinctrl_get(to_of_node(parent));
if (!pctldev)
return -ENODEV;

Expand Down Expand Up @@ -641,10 +642,11 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)

static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
{
struct device_node *node = to_of_node(bank->fwnode);
struct resource res;
int id = 0;

if (of_address_to_resource(bank->of_node, 0, &res)) {
if (of_address_to_resource(node, 0, &res)) {
dev_err(bank->dev, "cannot find IO resource for bank\n");
return -ENOENT;
}
Expand All @@ -653,11 +655,11 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
if (IS_ERR(bank->reg_base))
return PTR_ERR(bank->reg_base);

bank->irq = irq_of_parse_and_map(bank->of_node, 0);
bank->irq = irq_of_parse_and_map(node, 0);
if (!bank->irq)
return -EINVAL;

bank->clk = of_clk_get(bank->of_node, 0);
bank->clk = of_clk_get(node, 0);
if (IS_ERR(bank->clk))
return PTR_ERR(bank->clk);

Expand All @@ -668,7 +670,7 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank)
if (id == GPIO_TYPE_V2 || id == GPIO_TYPE_V2_1) {
bank->gpio_regs = &gpio_regs_v2;
bank->gpio_type = GPIO_TYPE_V2;
bank->db_clk = of_clk_get(bank->of_node, 1);
bank->db_clk = of_clk_get(node, 1);
if (IS_ERR(bank->db_clk)) {
dev_err(bank->dev, "cannot find debounce clk\n");
clk_disable_unprepare(bank->clk);
Expand Down Expand Up @@ -704,22 +706,22 @@ rockchip_gpio_find_bank(struct pinctrl_dev *pctldev, int id)
static int rockchip_gpio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct device_node *pctlnp = of_get_parent(np);
struct fwnode_handle *fwnode = dev_fwnode(dev);
struct fwnode_handle *parent = fwnode_get_parent(fwnode);
struct pinctrl_dev *pctldev = NULL;
struct rockchip_pin_bank *bank = NULL;
struct rockchip_pin_deferred *cfg;
static int gpio;
int id, ret;

if (!np || !pctlnp)
if (!parent)
return -ENODEV;

pctldev = of_pinctrl_get(pctlnp);
pctldev = of_pinctrl_get(to_of_node(parent));
if (!pctldev)
return -EPROBE_DEFER;

id = of_alias_get_id(np, "gpio");
id = of_alias_get_id(to_of_node(fwnode), "gpio");
if (id < 0)
id = gpio++;

Expand All @@ -728,7 +730,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
return -EINVAL;

bank->dev = dev;
bank->of_node = np;
bank->fwnode = fwnode;

raw_spin_lock_init(&bank->slock);

Expand Down Expand Up @@ -776,7 +778,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
mutex_unlock(&bank->deferred_lock);

platform_set_drvdata(pdev, bank);
dev_info(dev, "probed %pOF\n", np);
dev_info(dev, "probed %pfw\n", fwnode);

return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/pinctrl/pinctrl-rockchip.h
Expand Up @@ -18,6 +18,8 @@
#ifndef _PINCTRL_ROCKCHIP_H
#define _PINCTRL_ROCKCHIP_H

struct fwnode_handle;

#define RK_GPIO0_A0 0
#define RK_GPIO0_A1 1
#define RK_GPIO0_A2 2
Expand Down Expand Up @@ -298,7 +300,7 @@ struct rockchip_drv {
* @drv: array describing the 4 drive strength sources of the bank
* @pull_type: array describing the 4 pull type sources of the bank
* @valid: is all necessary information present
* @of_node: dt node of this bank
* @fwnode: firmware node of this bank
* @drvdata: common pinctrl basedata
* @domain: irqdomain of the gpio bank
* @gpio_chip: gpiolib chip
Expand Down Expand Up @@ -326,7 +328,7 @@ struct rockchip_pin_bank {
struct rockchip_drv drv[4];
enum rockchip_pin_pull_type pull_type[4];
bool valid;
struct device_node *of_node;
struct fwnode_handle *fwnode;
struct rockchip_pinctrl *drvdata;
struct irq_domain *domain;
struct gpio_chip gpio_chip;
Expand Down

0 comments on commit 678cf64

Please sign in to comment.