Thread (12 messages) flat view 12 messages, 3 authors, 2016-02-08

Re: [PATCH 4/7] net: phy: spi_ks8995: add support for resetting switch using GPIO

From: Andrew Lunn <andrew@lunn.ch>
Date: 2016-02-08 09:22:08

On Sun, Feb 07, 2016 at 11:39:10PM +0100, Helmut Buchsbaum wrote:
When using device tree it is no more possible to reset the PHY at board
level. Furthermore, doing in the driver allows to power down the switch
when the it is not used any more.

The patch introduces a new optional property "reset-gpios" denoting an
appropriate GPIO handle, e.g.:

reset-gpios = <&gpio0 46 1>
The 1 here means active low flag.
 
+	pdata->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0);
+
Here you don't take any notice of the flags.
quoted hunk ↗ jump to hunk
 	/* we have something like:
 	 * settings = <0x22 0x80 0xF0>;
 	 *               ^   ^    ^
@@ -484,6 +489,8 @@ static int ks8995_probe(struct spi_device *spi)
 		if (!ks->pdata)
 			return -ENOMEM;
 
+		ks->pdata->reset_gpio = -1;
+
 		err = ks8995_parse_dt(ks);
 		if (err) {
 			dev_err(&ks->spi->dev, "bad data DT data\n");
@@ -494,6 +501,18 @@ static int ks8995_probe(struct spi_device *spi)
 	if (!ks->pdata)
 		ks->pdata = spi->dev.platform_data;
 
+	if (ks->pdata && gpio_is_valid(ks->pdata->reset_gpio)) {
+		err = devm_gpio_request_one(&spi->dev,
+					    ks->pdata->reset_gpio,
+					    GPIOF_OUT_INIT_HIGH,
Hard coded HIGH. You should determine this from the flag....

DSA has the same functionality and does support the flag. You can copy
it from there.

     Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help