xref: /openbmc/linux/drivers/gpio/gpio-stp-xway.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
25238f7bcSJohn Crispin /*
35238f7bcSJohn Crispin  *
4baddc7caSJohn Crispin  *  Copyright (C) 2012 John Crispin <john@phrozen.org>
55238f7bcSJohn Crispin  */
65238f7bcSJohn Crispin 
7*e91d0f05SRob Herring #include <linux/platform_device.h>
85238f7bcSJohn Crispin #include <linux/slab.h>
95238f7bcSJohn Crispin #include <linux/init.h>
1054f30066SJohn Crispin #include <linux/module.h>
115238f7bcSJohn Crispin #include <linux/types.h>
12*e91d0f05SRob Herring #include <linux/of.h>
135238f7bcSJohn Crispin #include <linux/mutex.h>
1497a48fcdSLinus Walleij #include <linux/gpio/driver.h>
1554f30066SJohn Crispin #include <linux/io.h>
1654f30066SJohn Crispin #include <linux/clk.h>
1754f30066SJohn Crispin #include <linux/err.h>
185238f7bcSJohn Crispin 
1954f30066SJohn Crispin /*
2054f30066SJohn Crispin  * The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a
2154f30066SJohn Crispin  * peripheral controller used to drive external shift register cascades. At most
2254f30066SJohn Crispin  * 3 groups of 8 bits can be driven. The hardware is able to allow the DSL modem
2354f30066SJohn Crispin  * to drive the 2 LSBs of the cascade automatically.
2454f30066SJohn Crispin  */
255238f7bcSJohn Crispin 
2654f30066SJohn Crispin /* control register 0 */
2754f30066SJohn Crispin #define XWAY_STP_CON0		0x00
2854f30066SJohn Crispin /* control register 1 */
2954f30066SJohn Crispin #define XWAY_STP_CON1		0x04
3054f30066SJohn Crispin /* data register 0 */
3154f30066SJohn Crispin #define XWAY_STP_CPU0		0x08
3254f30066SJohn Crispin /* data register 1 */
3354f30066SJohn Crispin #define XWAY_STP_CPU1		0x0C
3454f30066SJohn Crispin /* access register */
3554f30066SJohn Crispin #define XWAY_STP_AR		0x10
365238f7bcSJohn Crispin 
3754f30066SJohn Crispin /* software or hardware update select bit */
3854f30066SJohn Crispin #define XWAY_STP_CON_SWU	BIT(31)
395238f7bcSJohn Crispin 
4054f30066SJohn Crispin /* automatic update rates */
4154f30066SJohn Crispin #define XWAY_STP_2HZ		0
4254f30066SJohn Crispin #define XWAY_STP_4HZ		BIT(23)
4354f30066SJohn Crispin #define XWAY_STP_8HZ		BIT(24)
4454f30066SJohn Crispin #define XWAY_STP_10HZ		(BIT(24) | BIT(23))
45329afb94SAleksander Jan Bajkowski #define XWAY_STP_SPEED_MASK	(BIT(23) | BIT(24) | BIT(25) | BIT(26) | BIT(27))
46329afb94SAleksander Jan Bajkowski 
47329afb94SAleksander Jan Bajkowski #define XWAY_STP_FPIS_VALUE	BIT(21)
48329afb94SAleksander Jan Bajkowski #define XWAY_STP_FPIS_MASK	(BIT(20) | BIT(21))
495238f7bcSJohn Crispin 
5054f30066SJohn Crispin /* clock source for automatic update */
5154f30066SJohn Crispin #define XWAY_STP_UPD_FPI	BIT(31)
5254f30066SJohn Crispin #define XWAY_STP_UPD_MASK	(BIT(31) | BIT(30))
535238f7bcSJohn Crispin 
5454f30066SJohn Crispin /* let the adsl core drive the 2 LSBs */
5554f30066SJohn Crispin #define XWAY_STP_ADSL_SHIFT	24
5654f30066SJohn Crispin #define XWAY_STP_ADSL_MASK	0x3
575238f7bcSJohn Crispin 
5854f30066SJohn Crispin /* 2 groups of 3 bits can be driven by the phys */
5908b085a0SMartin Blumenstingl #define XWAY_STP_PHY_MASK	0x7
6054f30066SJohn Crispin #define XWAY_STP_PHY1_SHIFT	27
61329afb94SAleksander Jan Bajkowski #define XWAY_STP_PHY2_SHIFT	3
62329afb94SAleksander Jan Bajkowski #define XWAY_STP_PHY3_SHIFT	6
63329afb94SAleksander Jan Bajkowski #define XWAY_STP_PHY4_SHIFT	15
645238f7bcSJohn Crispin 
6554f30066SJohn Crispin /* STP has 3 groups of 8 bits */
6654f30066SJohn Crispin #define XWAY_STP_GROUP0		BIT(0)
6754f30066SJohn Crispin #define XWAY_STP_GROUP1		BIT(1)
6854f30066SJohn Crispin #define XWAY_STP_GROUP2		BIT(2)
6954f30066SJohn Crispin #define XWAY_STP_GROUP_MASK	(0x7)
705238f7bcSJohn Crispin 
7154f30066SJohn Crispin /* Edge configuration bits */
7254f30066SJohn Crispin #define XWAY_STP_FALLING	BIT(26)
7354f30066SJohn Crispin #define XWAY_STP_EDGE_MASK	BIT(26)
745238f7bcSJohn Crispin 
7554f30066SJohn Crispin #define xway_stp_r32(m, reg)		__raw_readl(m + reg)
7654f30066SJohn Crispin #define xway_stp_w32(m, val, reg)	__raw_writel(val, m + reg)
7754f30066SJohn Crispin #define xway_stp_w32_mask(m, clear, set, reg) \
78c0ec7012SMartin Blumenstingl 		xway_stp_w32(m, (xway_stp_r32(m, reg) & ~(clear)) | (set), reg)
7954f30066SJohn Crispin 
8054f30066SJohn Crispin struct xway_stp {
8154f30066SJohn Crispin 	struct gpio_chip gc;
8254f30066SJohn Crispin 	void __iomem *virt;
8354f30066SJohn Crispin 	u32 edge;	/* rising or falling edge triggered shift register */
84c9e854cfSJohn Crispin 	u32 shadow;	/* shadow the shift registers state */
8554f30066SJohn Crispin 	u8 groups;	/* we can drive 1-3 groups of 8bit each */
8654f30066SJohn Crispin 	u8 dsl;		/* the 2 LSBs can be driven by the dsl core */
8754f30066SJohn Crispin 	u8 phy1;	/* 3 bits can be driven by phy1 */
8854f30066SJohn Crispin 	u8 phy2;	/* 3 bits can be driven by phy2 */
89329afb94SAleksander Jan Bajkowski 	u8 phy3;	/* 3 bits can be driven by phy3 */
90329afb94SAleksander Jan Bajkowski 	u8 phy4;	/* 3 bits can be driven by phy4 */
9154f30066SJohn Crispin 	u8 reserved;	/* mask out the hw driven bits in gpio_request */
925238f7bcSJohn Crispin };
935238f7bcSJohn Crispin 
9454f30066SJohn Crispin /**
955b9b2b52SMathias Kresin  * xway_stp_get() - gpio_chip->get - get gpios.
965b9b2b52SMathias Kresin  * @gc:     Pointer to gpio_chip device structure.
975b9b2b52SMathias Kresin  * @gpio:   GPIO signal number.
985b9b2b52SMathias Kresin  *
995b9b2b52SMathias Kresin  * Gets the shadow value.
1005b9b2b52SMathias Kresin  */
xway_stp_get(struct gpio_chip * gc,unsigned int gpio)1015b9b2b52SMathias Kresin static int xway_stp_get(struct gpio_chip *gc, unsigned int gpio)
1025b9b2b52SMathias Kresin {
1035b9b2b52SMathias Kresin 	struct xway_stp *chip = gpiochip_get_data(gc);
1045b9b2b52SMathias Kresin 
1055b9b2b52SMathias Kresin 	return (xway_stp_r32(chip->virt, XWAY_STP_CPU0) & BIT(gpio));
1065b9b2b52SMathias Kresin }
1075b9b2b52SMathias Kresin 
1085b9b2b52SMathias Kresin /**
10954f30066SJohn Crispin  * xway_stp_set() - gpio_chip->set - set gpios.
11054f30066SJohn Crispin  * @gc:     Pointer to gpio_chip device structure.
11154f30066SJohn Crispin  * @gpio:   GPIO signal number.
11254f30066SJohn Crispin  * @val:    Value to be written to specified signal.
11354f30066SJohn Crispin  *
11454f30066SJohn Crispin  * Set the shadow value and call ltq_ebu_apply.
1155238f7bcSJohn Crispin  */
xway_stp_set(struct gpio_chip * gc,unsigned gpio,int val)11654f30066SJohn Crispin static void xway_stp_set(struct gpio_chip *gc, unsigned gpio, int val)
11754f30066SJohn Crispin {
118c63b30b0SLinus Walleij 	struct xway_stp *chip = gpiochip_get_data(gc);
1195238f7bcSJohn Crispin 
12054f30066SJohn Crispin 	if (val)
12154f30066SJohn Crispin 		chip->shadow |= BIT(gpio);
12254f30066SJohn Crispin 	else
12354f30066SJohn Crispin 		chip->shadow &= ~BIT(gpio);
12454f30066SJohn Crispin 	xway_stp_w32(chip->virt, chip->shadow, XWAY_STP_CPU0);
125329afb94SAleksander Jan Bajkowski 	if (!chip->reserved)
12654f30066SJohn Crispin 		xway_stp_w32_mask(chip->virt, 0, XWAY_STP_CON_SWU, XWAY_STP_CON0);
12754f30066SJohn Crispin }
12854f30066SJohn Crispin 
12954f30066SJohn Crispin /**
13054f30066SJohn Crispin  * xway_stp_dir_out() - gpio_chip->dir_out - set gpio direction.
13154f30066SJohn Crispin  * @gc:     Pointer to gpio_chip device structure.
13254f30066SJohn Crispin  * @gpio:   GPIO signal number.
13354f30066SJohn Crispin  * @val:    Value to be written to specified signal.
13454f30066SJohn Crispin  *
13554f30066SJohn Crispin  * Same as xway_stp_set, always returns 0.
13654f30066SJohn Crispin  */
xway_stp_dir_out(struct gpio_chip * gc,unsigned gpio,int val)13754f30066SJohn Crispin static int xway_stp_dir_out(struct gpio_chip *gc, unsigned gpio, int val)
13854f30066SJohn Crispin {
13954f30066SJohn Crispin 	xway_stp_set(gc, gpio, val);
14054f30066SJohn Crispin 
1415238f7bcSJohn Crispin 	return 0;
1425238f7bcSJohn Crispin }
1435238f7bcSJohn Crispin 
14454f30066SJohn Crispin /**
14554f30066SJohn Crispin  * xway_stp_request() - gpio_chip->request
14654f30066SJohn Crispin  * @gc:     Pointer to gpio_chip device structure.
14754f30066SJohn Crispin  * @gpio:   GPIO signal number.
14854f30066SJohn Crispin  *
14954f30066SJohn Crispin  * We mask out the HW driven pins
15054f30066SJohn Crispin  */
xway_stp_request(struct gpio_chip * gc,unsigned gpio)15154f30066SJohn Crispin static int xway_stp_request(struct gpio_chip *gc, unsigned gpio)
15254f30066SJohn Crispin {
153c63b30b0SLinus Walleij 	struct xway_stp *chip = gpiochip_get_data(gc);
15454f30066SJohn Crispin 
15554f30066SJohn Crispin 	if ((gpio < 8) && (chip->reserved & BIT(gpio))) {
15658383c78SLinus Walleij 		dev_err(gc->parent, "GPIO %d is driven by hardware\n", gpio);
15754f30066SJohn Crispin 		return -ENODEV;
15854f30066SJohn Crispin 	}
15954f30066SJohn Crispin 
16054f30066SJohn Crispin 	return 0;
16154f30066SJohn Crispin }
16254f30066SJohn Crispin 
16354f30066SJohn Crispin /**
16454f30066SJohn Crispin  * xway_stp_hw_init() - Configure the STP unit and enable the clock gate
1658a7b1797SMartin Blumenstingl  * @chip: Pointer to the xway_stp chip structure
16654f30066SJohn Crispin  */
xway_stp_hw_init(struct xway_stp * chip)1678a7b1797SMartin Blumenstingl static void xway_stp_hw_init(struct xway_stp *chip)
16854f30066SJohn Crispin {
16954f30066SJohn Crispin 	/* sane defaults */
17054f30066SJohn Crispin 	xway_stp_w32(chip->virt, 0, XWAY_STP_AR);
17154f30066SJohn Crispin 	xway_stp_w32(chip->virt, 0, XWAY_STP_CPU0);
17254f30066SJohn Crispin 	xway_stp_w32(chip->virt, 0, XWAY_STP_CPU1);
17354f30066SJohn Crispin 	xway_stp_w32(chip->virt, XWAY_STP_CON_SWU, XWAY_STP_CON0);
17454f30066SJohn Crispin 	xway_stp_w32(chip->virt, 0, XWAY_STP_CON1);
17554f30066SJohn Crispin 
17654f30066SJohn Crispin 	/* apply edge trigger settings for the shift register */
17754f30066SJohn Crispin 	xway_stp_w32_mask(chip->virt, XWAY_STP_EDGE_MASK,
17854f30066SJohn Crispin 				chip->edge, XWAY_STP_CON0);
17954f30066SJohn Crispin 
18054f30066SJohn Crispin 	/* apply led group settings */
18154f30066SJohn Crispin 	xway_stp_w32_mask(chip->virt, XWAY_STP_GROUP_MASK,
18254f30066SJohn Crispin 				chip->groups, XWAY_STP_CON1);
18354f30066SJohn Crispin 
18454f30066SJohn Crispin 	/* tell the hardware which pins are controlled by the dsl modem */
18554f30066SJohn Crispin 	xway_stp_w32_mask(chip->virt,
18654f30066SJohn Crispin 			XWAY_STP_ADSL_MASK << XWAY_STP_ADSL_SHIFT,
18754f30066SJohn Crispin 			chip->dsl << XWAY_STP_ADSL_SHIFT,
18854f30066SJohn Crispin 			XWAY_STP_CON0);
18954f30066SJohn Crispin 
19054f30066SJohn Crispin 	/* tell the hardware which pins are controlled by the phys */
19154f30066SJohn Crispin 	xway_stp_w32_mask(chip->virt,
19254f30066SJohn Crispin 			XWAY_STP_PHY_MASK << XWAY_STP_PHY1_SHIFT,
19354f30066SJohn Crispin 			chip->phy1 << XWAY_STP_PHY1_SHIFT,
19454f30066SJohn Crispin 			XWAY_STP_CON0);
19554f30066SJohn Crispin 	xway_stp_w32_mask(chip->virt,
19654f30066SJohn Crispin 			XWAY_STP_PHY_MASK << XWAY_STP_PHY2_SHIFT,
19754f30066SJohn Crispin 			chip->phy2 << XWAY_STP_PHY2_SHIFT,
19854f30066SJohn Crispin 			XWAY_STP_CON1);
19954f30066SJohn Crispin 
200329afb94SAleksander Jan Bajkowski 	if (of_machine_is_compatible("lantiq,grx390")
201329afb94SAleksander Jan Bajkowski 	    || of_machine_is_compatible("lantiq,ar10")) {
202329afb94SAleksander Jan Bajkowski 		xway_stp_w32_mask(chip->virt,
203329afb94SAleksander Jan Bajkowski 				XWAY_STP_PHY_MASK << XWAY_STP_PHY3_SHIFT,
204329afb94SAleksander Jan Bajkowski 				chip->phy3 << XWAY_STP_PHY3_SHIFT,
205329afb94SAleksander Jan Bajkowski 				XWAY_STP_CON1);
206329afb94SAleksander Jan Bajkowski 	}
207329afb94SAleksander Jan Bajkowski 
208329afb94SAleksander Jan Bajkowski 	if (of_machine_is_compatible("lantiq,grx390")) {
209329afb94SAleksander Jan Bajkowski 		xway_stp_w32_mask(chip->virt,
210329afb94SAleksander Jan Bajkowski 				XWAY_STP_PHY_MASK << XWAY_STP_PHY4_SHIFT,
211329afb94SAleksander Jan Bajkowski 				chip->phy4 << XWAY_STP_PHY4_SHIFT,
212329afb94SAleksander Jan Bajkowski 				XWAY_STP_CON1);
213329afb94SAleksander Jan Bajkowski 	}
214329afb94SAleksander Jan Bajkowski 
21554f30066SJohn Crispin 	/* mask out the hw driven bits in gpio_request */
216329afb94SAleksander Jan Bajkowski 	chip->reserved = (chip->phy4 << 11) | (chip->phy3 << 8) | (chip->phy2 << 5)
217329afb94SAleksander Jan Bajkowski 		| (chip->phy1 << 2) | chip->dsl;
21854f30066SJohn Crispin 
21954f30066SJohn Crispin 	/*
22054f30066SJohn Crispin 	 * if we have pins that are driven by hw, we need to tell the stp what
22154f30066SJohn Crispin 	 * clock to use as a timer.
22254f30066SJohn Crispin 	 */
223329afb94SAleksander Jan Bajkowski 	if (chip->reserved) {
22454f30066SJohn Crispin 		xway_stp_w32_mask(chip->virt, XWAY_STP_UPD_MASK,
22554f30066SJohn Crispin 			XWAY_STP_UPD_FPI, XWAY_STP_CON1);
226329afb94SAleksander Jan Bajkowski 		xway_stp_w32_mask(chip->virt, XWAY_STP_SPEED_MASK,
227329afb94SAleksander Jan Bajkowski 			XWAY_STP_10HZ, XWAY_STP_CON1);
228329afb94SAleksander Jan Bajkowski 		xway_stp_w32_mask(chip->virt, XWAY_STP_FPIS_MASK,
229329afb94SAleksander Jan Bajkowski 			XWAY_STP_FPIS_VALUE, XWAY_STP_CON1);
230329afb94SAleksander Jan Bajkowski 	}
23154f30066SJohn Crispin }
23254f30066SJohn Crispin 
xway_stp_probe(struct platform_device * pdev)2333836309dSBill Pemberton static int xway_stp_probe(struct platform_device *pdev)
2345238f7bcSJohn Crispin {
23550f09073SMartin Blumenstingl 	u32 shadow, groups, dsl, phy;
23654f30066SJohn Crispin 	struct xway_stp *chip;
23754f30066SJohn Crispin 	struct clk *clk;
2385238f7bcSJohn Crispin 	int ret = 0;
2395238f7bcSJohn Crispin 
24054f30066SJohn Crispin 	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
24154f30066SJohn Crispin 	if (!chip)
24254f30066SJohn Crispin 		return -ENOMEM;
24354f30066SJohn Crispin 
2446ba7c53bSEnrico Weigelt, metux IT consult 	chip->virt = devm_platform_ioremap_resource(pdev, 0);
245641d0342SThierry Reding 	if (IS_ERR(chip->virt))
246641d0342SThierry Reding 		return PTR_ERR(chip->virt);
247641d0342SThierry Reding 
24858383c78SLinus Walleij 	chip->gc.parent = &pdev->dev;
24954f30066SJohn Crispin 	chip->gc.label = "stp-xway";
25054f30066SJohn Crispin 	chip->gc.direction_output = xway_stp_dir_out;
2515b9b2b52SMathias Kresin 	chip->gc.get = xway_stp_get;
25254f30066SJohn Crispin 	chip->gc.set = xway_stp_set;
25354f30066SJohn Crispin 	chip->gc.request = xway_stp_request;
25454f30066SJohn Crispin 	chip->gc.base = -1;
25554f30066SJohn Crispin 	chip->gc.owner = THIS_MODULE;
25654f30066SJohn Crispin 
25754f30066SJohn Crispin 	/* store the shadow value if one was passed by the devicetree */
25850f09073SMartin Blumenstingl 	if (!of_property_read_u32(pdev->dev.of_node, "lantiq,shadow", &shadow))
25950f09073SMartin Blumenstingl 		chip->shadow = shadow;
26054f30066SJohn Crispin 
26154f30066SJohn Crispin 	/* find out which gpio groups should be enabled */
26250f09073SMartin Blumenstingl 	if (!of_property_read_u32(pdev->dev.of_node, "lantiq,groups", &groups))
26350f09073SMartin Blumenstingl 		chip->groups = groups & XWAY_STP_GROUP_MASK;
26454f30066SJohn Crispin 	else
26554f30066SJohn Crispin 		chip->groups = XWAY_STP_GROUP0;
26654f30066SJohn Crispin 	chip->gc.ngpio = fls(chip->groups) * 8;
26754f30066SJohn Crispin 
26854f30066SJohn Crispin 	/* find out which gpios are controlled by the dsl core */
26950f09073SMartin Blumenstingl 	if (!of_property_read_u32(pdev->dev.of_node, "lantiq,dsl", &dsl))
27050f09073SMartin Blumenstingl 		chip->dsl = dsl & XWAY_STP_ADSL_MASK;
27154f30066SJohn Crispin 
27254f30066SJohn Crispin 	/* find out which gpios are controlled by the phys */
27354f30066SJohn Crispin 	if (of_machine_is_compatible("lantiq,ar9") ||
27454f30066SJohn Crispin 			of_machine_is_compatible("lantiq,gr9") ||
275329afb94SAleksander Jan Bajkowski 			of_machine_is_compatible("lantiq,vr9") ||
276329afb94SAleksander Jan Bajkowski 			of_machine_is_compatible("lantiq,ar10") ||
277329afb94SAleksander Jan Bajkowski 			of_machine_is_compatible("lantiq,grx390")) {
27850f09073SMartin Blumenstingl 		if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy1", &phy))
27950f09073SMartin Blumenstingl 			chip->phy1 = phy & XWAY_STP_PHY_MASK;
28050f09073SMartin Blumenstingl 		if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy2", &phy))
28150f09073SMartin Blumenstingl 			chip->phy2 = phy & XWAY_STP_PHY_MASK;
28254f30066SJohn Crispin 	}
28354f30066SJohn Crispin 
284329afb94SAleksander Jan Bajkowski 	if (of_machine_is_compatible("lantiq,ar10") ||
285329afb94SAleksander Jan Bajkowski 			of_machine_is_compatible("lantiq,grx390")) {
286329afb94SAleksander Jan Bajkowski 		if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy3", &phy))
287329afb94SAleksander Jan Bajkowski 			chip->phy3 = phy & XWAY_STP_PHY_MASK;
288329afb94SAleksander Jan Bajkowski 	}
289329afb94SAleksander Jan Bajkowski 
290329afb94SAleksander Jan Bajkowski 	if (of_machine_is_compatible("lantiq,grx390")) {
291329afb94SAleksander Jan Bajkowski 		if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy4", &phy))
292329afb94SAleksander Jan Bajkowski 			chip->phy4 = phy & XWAY_STP_PHY_MASK;
293329afb94SAleksander Jan Bajkowski 	}
294329afb94SAleksander Jan Bajkowski 
29554f30066SJohn Crispin 	/* check which edge trigger we should use, default to a falling edge */
2965b0ad5b2SRob Herring 	if (!of_property_read_bool(pdev->dev.of_node, "lantiq,rising"))
29754f30066SJohn Crispin 		chip->edge = XWAY_STP_FALLING;
29854f30066SJohn Crispin 
299bd791c48SMartin Blumenstingl 	clk = devm_clk_get(&pdev->dev, NULL);
30054f30066SJohn Crispin 	if (IS_ERR(clk)) {
30154f30066SJohn Crispin 		dev_err(&pdev->dev, "Failed to get clock\n");
30254f30066SJohn Crispin 		return PTR_ERR(clk);
30354f30066SJohn Crispin 	}
30454f30066SJohn Crispin 
305bd791c48SMartin Blumenstingl 	ret = clk_prepare_enable(clk);
306bd791c48SMartin Blumenstingl 	if (ret)
307bd791c48SMartin Blumenstingl 		return ret;
30854f30066SJohn Crispin 
3098a7b1797SMartin Blumenstingl 	xway_stp_hw_init(chip);
31054f30066SJohn Crispin 
3115238f7bcSJohn Crispin 	ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip);
312bd791c48SMartin Blumenstingl 	if (ret) {
313bd791c48SMartin Blumenstingl 		clk_disable_unprepare(clk);
3148a7b1797SMartin Blumenstingl 		return ret;
315bd791c48SMartin Blumenstingl 	}
31654f30066SJohn Crispin 
31754f30066SJohn Crispin 	dev_info(&pdev->dev, "Init done\n");
3185238f7bcSJohn Crispin 
3198a7b1797SMartin Blumenstingl 	return 0;
3205238f7bcSJohn Crispin }
3215238f7bcSJohn Crispin 
32254f30066SJohn Crispin static const struct of_device_id xway_stp_match[] = {
32354f30066SJohn Crispin 	{ .compatible = "lantiq,gpio-stp-xway" },
32454f30066SJohn Crispin 	{},
32554f30066SJohn Crispin };
32654f30066SJohn Crispin MODULE_DEVICE_TABLE(of, xway_stp_match);
32754f30066SJohn Crispin 
32854f30066SJohn Crispin static struct platform_driver xway_stp_driver = {
32954f30066SJohn Crispin 	.probe = xway_stp_probe,
3305238f7bcSJohn Crispin 	.driver = {
33154f30066SJohn Crispin 		.name = "gpio-stp-xway",
33254f30066SJohn Crispin 		.of_match_table = xway_stp_match,
3335238f7bcSJohn Crispin 	},
3345238f7bcSJohn Crispin };
3355238f7bcSJohn Crispin 
xway_stp_init(void)336afdadc06SLinus Walleij static int __init xway_stp_init(void)
3375238f7bcSJohn Crispin {
33854f30066SJohn Crispin 	return platform_driver_register(&xway_stp_driver);
3395238f7bcSJohn Crispin }
3405238f7bcSJohn Crispin 
34154f30066SJohn Crispin subsys_initcall(xway_stp_init);
342