On 02/24/2015 11:11 AM, Alexander Aring wrote: > This patch adds support for setting the xtal trim register. Some at86rf2xx > transceiver boards needs fine tuning the xtal capacitor. > > Signed-off-by: Alexander Aring <alex.aring@xxxxxxxxx> > --- > .../devicetree/bindings/net/ieee802154/at86rf230.txt | 3 +++ > drivers/net/ieee802154/at86rf230.c | 12 ++++++++++++ > include/linux/spi/at86rf230.h | 1 + > 3 files changed, 16 insertions(+) > > diff --git a/Documentation/devicetree/bindings/net/ieee802154/at86rf230.txt b/Documentation/devicetree/bindings/net/ieee802154/at86rf230.txt > index d3bbdded..1ae5100 100644 > --- a/Documentation/devicetree/bindings/net/ieee802154/at86rf230.txt > +++ b/Documentation/devicetree/bindings/net/ieee802154/at86rf230.txt > @@ -11,6 +11,8 @@ Required properties: > Optional properties: > - reset-gpio: GPIO spec for the rstn pin > - sleep-gpio: GPIO spec for the slp_tr pin > + - xtal-trim: u8 value for fine tuning the internal capacitance > + arrays of xtal pins: 0 = +0 pF, 0xf = +4.5 pF > > Example: > > @@ -20,4 +22,5 @@ Example: > reg = <0>; > interrupts = <19 1>; > interrupt-parent = <&gpio3>; > + xtal-trim = /bits/ 8 <0x06>; > }; > diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c > index c495f23..e74b3cc 100644 > --- a/drivers/net/ieee802154/at86rf230.c > +++ b/drivers/net/ieee802154/at86rf230.c > @@ -72,6 +72,7 @@ struct at86rf230_state_change { > > struct at86rf230_local { > struct spi_device *spi; > + struct at86rf230_platform_data cfg; > > struct ieee802154_hw *hw; > struct at86rf2xx_chip_data *data; > @@ -1362,6 +1363,10 @@ static int at86rf230_hw_init(struct at86rf230_local *lp) > usleep_range(lp->data->t_sleep_cycle, > lp->data->t_sleep_cycle + 100); > > + rc = at86rf230_write_subreg(lp, SR_XTAL_TRIM, lp->cfg.xtal_trim); > + if (rc) > + return rc; > + > rc = at86rf230_read_subreg(lp, SR_DVDD_OK, &dvdd); > if (rc) > return rc; > @@ -1380,6 +1385,8 @@ static int at86rf230_hw_init(struct at86rf230_local *lp) > static int at86rf230_get_pdata(struct spi_device *spi, > struct at86rf230_platform_data *cfg) > { > + int ret; > + > if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) { > if (!spi->dev.platform_data) > return -ENOENT; > @@ -1390,6 +1397,10 @@ static int at86rf230_get_pdata(struct spi_device *spi, > > cfg->rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0); > cfg->slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0); > + ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", > + &cfg->xtal_trim); > + if (ret < 0 && ret != -EINVAL) > + return ret; > > return 0; > } > @@ -1545,6 +1556,7 @@ static int at86rf230_probe(struct spi_device *spi) > lp = hw->priv; > lp->hw = hw; > lp->spi = spi; > + lp->cfg = cfg; This doesn't look correct. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Attachment:
signature.asc
Description: OpenPGP digital signature