* [PATCH 1/2] thermal: broadcom: Allow for NSP to use ns-thermal driver
From: Jon Mason @ 2017-04-25 20:49 UTC (permalink / raw)
To: Florian Fainelli, Zhang Rui, Eduardo Valentin, Rob Herring,
Mark Rutland
Cc: bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-pm-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1493153351-12698-1-git-send-email-jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
Change the iProc Kconfig to select THERMAL and THERMAL_OF, which allows
the ns-thermal driver to be selected via menuconfig. Also, change the
ns-thermal driver to work on any iProc based SoC. Finally, tweak the
Kconfig description to mention support for NSP and make the default on
for iProc based platforms.
Signed-off-by: Jon Mason <jon.mason-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
---
arch/arm/mach-bcm/Kconfig | 2 ++
drivers/thermal/broadcom/Kconfig | 9 +++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index a0e66d8..da2bfeb 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -19,6 +19,8 @@ config ARCH_BCM_IPROC
select GPIOLIB
select ARM_AMBA
select PINCTRL
+ select THERMAL
+ select THERMAL_OF
help
This enables support for systems based on Broadcom IPROC architected SoCs.
The IPROC complex contains one or more ARM CPUs along with common
diff --git a/drivers/thermal/broadcom/Kconfig b/drivers/thermal/broadcom/Kconfig
index f0dea8a..26d706c 100644
--- a/drivers/thermal/broadcom/Kconfig
+++ b/drivers/thermal/broadcom/Kconfig
@@ -1,8 +1,9 @@
config BCM_NS_THERMAL
tristate "Northstar thermal driver"
depends on ARCH_BCM_IPROC || COMPILE_TEST
+ default ARCH_BCM_IPROC
help
- Northstar is a family of SoCs that includes e.g. BCM4708, BCM47081,
- BCM4709 and BCM47094. It contains DMU (Device Management Unit) block
- with a thermal sensor that allows checking CPU temperature. This
- driver provides support for it.
+ Support for the Northstar and Northstar Plus family of SoCs (e.g.
+ BCM4708, BCM4709, BCM5301x, BCM95852X, etc). It contains DMU (Device
+ Management Unit) block with a thermal sensor that allows checking CPU
+ temperature.
--
2.7.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 2/2] ARM: dts: NSP: Add Thermal Support
From: Jon Mason @ 2017-04-25 20:49 UTC (permalink / raw)
To: Florian Fainelli, Zhang Rui, Eduardo Valentin, Rob Herring,
Mark Rutland
Cc: bcm-kernel-feedback-list, linux-arm-kernel, linux-kernel,
linux-pm, devicetree
In-Reply-To: <1493153351-12698-1-git-send-email-jon.mason@broadcom.com>
Add thermal support via the ns-thermal driver and create a single
thermal zone for the entire SoC.
Signed-off-by: Jon Mason <jon.mason@broadcom.com>
---
arch/arm/boot/dts/bcm-nsp.dtsi | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/arm/boot/dts/bcm-nsp.dtsi b/arch/arm/boot/dts/bcm-nsp.dtsi
index 832795b..be6fcfb 100644
--- a/arch/arm/boot/dts/bcm-nsp.dtsi
+++ b/arch/arm/boot/dts/bcm-nsp.dtsi
@@ -383,6 +383,12 @@
<0x3f408 0x04>;
};
+ thermal: thermal@3f2c0 {
+ compatible = "brcm,ns-thermal";
+ reg = <0x3f2c0 0x10>;
+ #thermal-sensor-cells = <0>;
+ };
+
sata_phy: sata_phy@40100 {
compatible = "brcm,iproc-nsp-sata-phy";
reg = <0x40100 0x340>;
@@ -533,4 +539,24 @@
brcm,pcie-msi-inten;
};
};
+
+ thermal-zones {
+ cpu-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <1000>;
+ coefficients = <(-556) 418000>;
+ thermal-sensors = <&thermal>;
+
+ trips {
+ cpu-crit {
+ temperature = <125000>;
+ hysteresis = <0>;
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ };
+ };
+ };
};
--
2.7.4
^ permalink raw reply related
* Re: [PATCH V2 0/2] correct ids for clk_testout
From: Heiko Stübner @ 2017-04-25 21:04 UTC (permalink / raw)
To: Eddie Cai
Cc: robh+dt, mark.rutland, zhengxing, mturquette, sboyd, devicetree,
linux-kernel, linux-clk, linux-arm-kernel, linux-rockchip
In-Reply-To: <1493102470-22965-1-git-send-email-eddie.cai.linux@gmail.com>
Hi Eddie,
Am Dienstag, 25. April 2017, 14:41:08 CEST schrieb Eddie Cai:
> we use clk_testout1 and clk_testout2 for camera. e.g. mipi 24M mclk. the ids
> of clk_testout1 and clk_testout2 is wrong. it's time to correct it.
Just to say, patches look good - thanks for explaining what the clocks are
going to be used for.
I'll apply them after 4.12-rc1 is released (in roughly 2.5 weeks), due to
needing a stable base for the clock-ids.
Heiko
^ permalink raw reply
* Re: [PATCH v2 1/2] of: support dtc compiler flags for overlays
From: Masahiro Yamada @ 2017-04-25 22:04 UTC (permalink / raw)
To: Frank Rowand
Cc: Rob Herring, Stephen Boyd, Michal Marek,
devicetree-u79uwXL29TY76Z2rM5mHXA, Linux Kernel Mailing List,
Linux Kbuild mailing list
In-Reply-To: <1493075119-32026-2-git-send-email-frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-25 8:05 GMT+09:00 <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> From: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
>
> The dtc compiler version that adds initial support was available
> in 4.11-rc1. Add the ability to set the dtc compiler flags needed
> by overlays.
>
> Signed-off-by: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
> ---
I know your motivation for 1/2 is overlay,
but this patch itself is more generic.
(support for per-file dtc compiler flag)
Could you reword the commit subject a little bit?
Otherwise,
Acked-by: Masahiro Yamada <yamada.masahiro-uWyLwvC0a2jby3iVrkZq2A@public.gmane.org>
> scripts/Makefile.lib | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 0a07f9014944..0bbec480d323 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -283,6 +283,8 @@ ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
> DTC_FLAGS += -Wno-unit_address_vs_reg
> endif
>
> +DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
> +
> # Generate an assembly file to wrap the output of the device tree compiler
> quiet_cmd_dt_S_dtb= DTB $@
> cmd_dt_S_dtb= \
> --
--
Best Regards
Masahiro Yamada
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v4 0/9] NFC: trf7970a: Fixups & convert to desc-based GPIO
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425184036.1212-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
On Tue, Apr 25, 2017 at 11:40:27AM -0700, Mark Greer wrote:
> These trf7970a driver patches do the following things:
> - add Mark Greer as the maintainer of the trf7970a driver
> - some minor fixups
> - remove support for 'vin-voltage-override' DT property
> - change the DTS example to indicate that EN and EN2 are active high GPIOs
> - convert the driver to use the descriptor-based GPIO interface
> - apply Lindent coding style fixes
>
> Based on nfc-next/master 4ea206395d3a ("nfc: fix get_unaligned_...() misuses")
>
> v3->v4:
> - Rebased on nfc-next/master because patches in that branch conflict
> with the v3 version of this patch series.
> - Removed "NFC: trf7970a: Don't manage EN2 when not specified in DT"
> because a similar patch has already been accepted.
> - Added "NFC: trf7970a: Clean up coding style issues" because the reason
> I removed it in v3 no longer exists.
> - Reordered the patches to make more sense (I think)
>
> v2->v3:
> - Removed "[PATCH v2 5/7] NFC: trf7970a: Clean up coding style issues"
> because it will make merging patches from Geoff Lansberry and others
> hard to apply. I will resubmit once those patches have been merged
> or rejected.
> - Added a patch to remove 'vin-voltage-override' DT property support as
> proper DT regulator set up makes it unnecessary.
>
> v1->v2:
> - Commit description fixups only; no functional changes.
>
> Mark Greer (9):
> MAINTAINERS: NFC: trf7970a: Add Mark Greer as maintainer
> NFC: trf7970a: Don't de-assert EN2 unless it was asserted
> NFC: trf7970a: Fix inaccurate comment in trf7970a_probe()
> NFC: trf7970a: Only check 'en2-rf-quirk' if EN2 is specified
> NFC: trf7970a: Remove useless comment
> NFC: trf7970a: Remove support for 'vin-voltage-override' DT property
> NFC: trf7970a: Enable pins are active high not active low
> NFC: trf7970a: Convert to descriptor based GPIO interface
> NFC: trf7970a: Clean up coding style issues
>
> .../devicetree/bindings/net/nfc/trf7970a.txt | 6 +-
> MAINTAINERS | 8 +
> drivers/nfc/Kconfig | 2 +-
> drivers/nfc/trf7970a.c | 363 ++++++++++-----------
> 4 files changed, 185 insertions(+), 194 deletions(-)
And...please ignore this one too as I missed a whitespace issue. :(
v5 on its way in just a minute.
Mark
--
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH v5 0/9] NFC: trf7970a: Fixups & convert to desc-based GPIO
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
These trf7970a driver patches do the following things:
- add Mark Greer as the maintainer of the trf7970a driver
- some minor fixups
- remove support for 'vin-voltage-override' DT property
- change the DTS example to indicate that EN and EN2 are active high GPIOs
- convert the driver to use the descriptor-based GPIO interface
- apply Lindent coding style fixes
Based on nfc-next/master 4ea206395d3a ("nfc: fix get_unaligned_...() misuses")
v4->v5:
- Fixed whitespace issue in "NFC: trf7970a: Clean up coding style issues"
v3->v4:
- Rebased on nfc-next/master because patches in that branch conflict
with the v3 version of this patch series.
- Removed "NFC: trf7970a: Don't manage EN2 when not specified in DT"
because a similar patch has already been accepted.
- Added "NFC: trf7970a: Clean up coding style issues" because the reason
I removed it in v3 no longer exists.
- Reordered the patches to make more sense (I think)
v2->v3:
- Removed "[PATCH v2 5/7] NFC: trf7970a: Clean up coding style issues"
because it will make merging patches from Geoff Lansberry and others
hard to apply. I will resubmit once those patches have been merged
or rejected.
- Added a patch to remove 'vin-voltage-override' DT property support as
proper DT regulator set up makes it unnecessary.
v1->v2:
- Commit description fixups only; no functional changes.
Mark Greer (9):
MAINTAINERS: NFC: trf7970a: Add Mark Greer as maintainer
NFC: trf7970a: Don't de-assert EN2 unless it was asserted
NFC: trf7970a: Fix inaccurate comment in trf7970a_probe()
NFC: trf7970a: Only check 'en2-rf-quirk' if EN2 is specified
NFC: trf7970a: Remove useless comment
NFC: trf7970a: Remove support for 'vin-voltage-override' DT property
NFC: trf7970a: Enable pins are active high not active low
NFC: trf7970a: Convert to descriptor based GPIO interface
NFC: trf7970a: Clean up coding style issues
.../devicetree/bindings/net/nfc/trf7970a.txt | 6 +-
MAINTAINERS | 8 +
drivers/nfc/Kconfig | 2 +-
drivers/nfc/trf7970a.c | 363 ++++++++++-----------
4 files changed, 185 insertions(+), 194 deletions(-)
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH v5 1/9] MAINTAINERS: NFC: trf7970a: Add Mark Greer as maintainer
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
Add Mark Greer as the maintainer of the trf7970a NFC driver.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
MAINTAINERS | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index a8eaa0a8e522..d7441b69f101 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11118,6 +11118,14 @@ F: kernel/time/alarmtimer.c
F: kernel/time/ntp.c
F: tools/testing/selftests/timers/
+TI TRF7970A NFC DRIVER
+M: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
+L: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
+L: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org (moderated for non-subscribers)
+S: Supported
+F: drivers/nfc/trf7970a.c
+F: Documentation/devicetree/bindings/net/nfc/trf7970a.txt
+
SC1200 WDT DRIVER
M: Zwane Mwaikambo <zwanem-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
S: Maintained
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 2/9] NFC: trf7970a: Don't de-assert EN2 unless it was asserted
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
When the trf7970a part has the bug related to 'en2-rf-quirk',
the GPIO connected to the EN2 pin will not be asserted by the
driver when powering up so it shouldn't be de-asserted when
powering down.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
drivers/nfc/trf7970a.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 2d1c8ca6e679..1a87525a88cd 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -1940,8 +1940,10 @@ static int trf7970a_power_down(struct trf7970a *trf)
}
gpio_set_value(trf->en_gpio, 0);
- if (gpio_is_valid(trf->en2_gpio))
- gpio_set_value(trf->en2_gpio, 0);
+
+ if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW))
+ if (gpio_is_valid(trf->en2_gpio))
+ gpio_set_value(trf->en2_gpio, 0);
ret = regulator_disable(trf->regulator);
if (ret)
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 3/9] NFC: trf7970a: Fix inaccurate comment in trf7970a_probe()
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
As of commit ce69b95ca4e4 ("NFC: Make EN2 pin optional in the
TRF7970A driver"), only the GPIO for the 'EN' enable pin needs
to be specified in the device tree so update the comments that
says both 'EN' and 'EN2' must be specified.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
drivers/nfc/trf7970a.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 1a87525a88cd..5d5a8b0e57d4 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -2046,7 +2046,7 @@ static int trf7970a_probe(struct spi_device *spi)
if (of_property_read_bool(np, "irq-status-read-quirk"))
trf->quirks |= TRF7970A_QUIRK_IRQ_STATUS_READ;
- /* There are two enable pins - both must be present */
+ /* There are two enable pins - only EN must be present in the DT */
trf->en_gpio = of_get_named_gpio(np, "ti,enable-gpios", 0);
if (!gpio_is_valid(trf->en_gpio)) {
dev_err(trf->dev, "No EN GPIO property\n");
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 4/9] NFC: trf7970a: Only check 'en2-rf-quirk' if EN2 is specified
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
The quirk indicated by the 'en2-rf-quirk' device tree property
is only relevant when there is a GPIO connected to the EN2 pin
of the trf7970a. This means we should only check for 'en2-rf-quirk'
when EN2 is specified in the 'ti,enable-gpios' property of the
device tree.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
drivers/nfc/trf7970a.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 5d5a8b0e57d4..4655680b0e7b 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -2070,6 +2070,9 @@ static int trf7970a_probe(struct spi_device *spi)
dev_err(trf->dev, "Can't request EN2 GPIO: %d\n", ret);
return ret;
}
+
+ if (of_property_read_bool(np, "en2-rf-quirk"))
+ trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;
}
of_property_read_u32(np, "clock-frequency", &clk_freq);
@@ -2081,9 +2084,6 @@ static int trf7970a_probe(struct spi_device *spi)
return -EINVAL;
}
- if (of_property_read_bool(np, "en2-rf-quirk"))
- trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;
-
ret = devm_request_threaded_irq(trf->dev, spi->irq, NULL,
trf7970a_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
"trf7970a", trf);
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 5/9] NFC: trf7970a: Remove useless comment
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
The last entry in the trf7970a_of_match[] table must be an empty
entry to demarcate the end of the table. Currently, there is a
comment indicating this but it is obvious so remove the comment.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
drivers/nfc/trf7970a.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 4655680b0e7b..b9a90843ea35 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -2273,7 +2273,7 @@ static const struct dev_pm_ops trf7970a_pm_ops = {
static const struct of_device_id trf7970a_of_match[] = {
{ .compatible = "ti,trf7970a", },
- { /* sentinel */ },
+ {},
};
MODULE_DEVICE_TABLE(of, trf7970a_of_match);
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 6/9] NFC: trf7970a: Remove support for 'vin-voltage-override' DT property
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
The 'vin-voltage-override' DT property is used by the trf7970a
driver to override the voltage presented to the driver by the
regulator subsystem. This is unnecessary as properly specifying
the regulator chain via DT properties will accomplish the same
thing. Therefore, remove support for 'vin-voltage-override'.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
Documentation/devicetree/bindings/net/nfc/trf7970a.txt | 2 --
drivers/nfc/trf7970a.c | 11 +----------
2 files changed, 1 insertion(+), 12 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
index c627bbb3009e..57cb52c94783 100644
--- a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
+++ b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
@@ -13,7 +13,6 @@ Optional SoC Specific Properties:
- pinctrl-names: Contains only one value - "default".
- pintctrl-0: Specifies the pin control groups used for this controller.
- autosuspend-delay: Specify autosuspend delay in milliseconds.
-- vin-voltage-override: Specify voltage of VIN pin in microvolts.
- irq-status-read-quirk: Specify that the trf7970a being used has the
"IRQ Status Read" erratum.
- en2-rf-quirk: Specify that the trf7970a being used has the "EN2 RF"
@@ -40,7 +39,6 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
ti,enable-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>,
<&gpio2 5 GPIO_ACTIVE_LOW>;
vin-supply = <&ldo3_reg>;
- vin-voltage-override = <5000000>;
vdd-io-supply = <&ldo2_reg>;
autosuspend-delay = <30000>;
irq-status-read-quirk;
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index b9a90843ea35..5827ad111942 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -2005,12 +2005,6 @@ static int trf7970a_get_autosuspend_delay(struct device_node *np)
return autosuspend_delay;
}
-static int trf7970a_get_vin_voltage_override(struct device_node *np,
- u32 *vin_uvolts)
-{
- return of_property_read_u32(np, "vin-voltage-override", vin_uvolts);
-}
-
static int trf7970a_probe(struct spi_device *spi)
{
struct device_node *np = spi->dev.of_node;
@@ -2108,10 +2102,7 @@ static int trf7970a_probe(struct spi_device *spi)
goto err_destroy_lock;
}
- ret = trf7970a_get_vin_voltage_override(np, &uvolts);
- if (ret)
- uvolts = regulator_get_voltage(trf->regulator);
-
+ uvolts = regulator_get_voltage(trf->regulator);
if (uvolts > 4000000)
trf->chip_status_ctrl = TRF7970A_CHIP_STATUS_VRS5_3;
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 7/9] NFC: trf7970a: Enable pins are active high not active low
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
The example DTS code for the trf7970a sets the GPIOs for the EN
and EN2 pins to active low when they are really active high so
correct the error.
Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
Documentation/devicetree/bindings/net/nfc/trf7970a.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
index 57cb52c94783..a24a93a4b010 100644
--- a/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
+++ b/Documentation/devicetree/bindings/net/nfc/trf7970a.txt
@@ -36,8 +36,8 @@ Example (for ARM-based BeagleBone with TRF7970A on SPI1):
spi-max-frequency = <2000000>;
interrupt-parent = <&gpio2>;
interrupts = <14 0>;
- ti,enable-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>,
- <&gpio2 5 GPIO_ACTIVE_LOW>;
+ ti,enable-gpios = <&gpio2 2 GPIO_ACTIVE_HIGH>,
+ <&gpio2 5 GPIO_ACTIVE_HIGH>;
vin-supply = <&ldo3_reg>;
vdd-io-supply = <&ldo2_reg>;
autosuspend-delay = <30000>;
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 8/9] NFC: trf7970a: Convert to descriptor based GPIO interface
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
The trf7970a driver uses the deprecated integer-based GPIO consumer
interface so convert it to use the new descriptor-based GPIO
consumer interface.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
drivers/nfc/Kconfig | 2 +-
drivers/nfc/trf7970a.c | 61 +++++++++++++++++++++-----------------------------
2 files changed, 26 insertions(+), 37 deletions(-)
diff --git a/drivers/nfc/Kconfig b/drivers/nfc/Kconfig
index c4208487fadc..b065eb605215 100644
--- a/drivers/nfc/Kconfig
+++ b/drivers/nfc/Kconfig
@@ -7,7 +7,7 @@ menu "Near Field Communication (NFC) devices"
config NFC_TRF7970A
tristate "Texas Instruments TRF7970a NFC driver"
- depends on SPI && NFC_DIGITAL
+ depends on SPI && NFC_DIGITAL && GPIOLIB
help
This option enables the NFC driver for Texas Instruments' TRF7970a
device. Such device supports 5 different protocols: ISO14443A,
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index 5827ad111942..bb777f50b4fb 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -20,9 +20,8 @@
#include <linux/nfc.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/spi/spi.h>
#include <linux/regulator/consumer.h>
@@ -452,8 +451,8 @@ struct trf7970a {
u8 tx_cmd;
bool issue_eof;
bool adjust_resp_len;
- int en2_gpio;
- int en_gpio;
+ struct gpio_desc *en_gpiod;
+ struct gpio_desc *en2_gpiod;
struct mutex lock;
unsigned int timeout;
bool ignore_timeout;
@@ -1908,14 +1907,13 @@ static int trf7970a_power_up(struct trf7970a *trf)
usleep_range(5000, 6000);
- if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) {
- if (gpio_is_valid(trf->en2_gpio)) {
- gpio_set_value(trf->en2_gpio, 1);
- usleep_range(1000, 2000);
- }
+ if (trf->en2_gpiod &&
+ !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW)) {
+ gpiod_set_value_cansleep(trf->en2_gpiod, 1);
+ usleep_range(1000, 2000);
}
- gpio_set_value(trf->en_gpio, 1);
+ gpiod_set_value_cansleep(trf->en_gpiod, 1);
usleep_range(20000, 21000);
@@ -1939,11 +1937,11 @@ static int trf7970a_power_down(struct trf7970a *trf)
return -EBUSY;
}
- gpio_set_value(trf->en_gpio, 0);
+ gpiod_set_value_cansleep(trf->en_gpiod, 0);
- if (!(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW))
- if (gpio_is_valid(trf->en2_gpio))
- gpio_set_value(trf->en2_gpio, 0);
+ if (trf->en2_gpiod &&
+ !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW))
+ gpiod_set_value_cansleep(trf->en2_gpiod, 0);
ret = regulator_disable(trf->regulator);
if (ret)
@@ -2041,32 +2039,23 @@ static int trf7970a_probe(struct spi_device *spi)
trf->quirks |= TRF7970A_QUIRK_IRQ_STATUS_READ;
/* There are two enable pins - only EN must be present in the DT */
- trf->en_gpio = of_get_named_gpio(np, "ti,enable-gpios", 0);
- if (!gpio_is_valid(trf->en_gpio)) {
+ trf->en_gpiod = devm_gpiod_get_index(trf->dev, "ti,enable", 0,
+ GPIOD_OUT_LOW);
+ if (IS_ERR(trf->en_gpiod)) {
dev_err(trf->dev, "No EN GPIO property\n");
- return trf->en_gpio;
- }
-
- ret = devm_gpio_request_one(trf->dev, trf->en_gpio,
- GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN");
- if (ret) {
- dev_err(trf->dev, "Can't request EN GPIO: %d\n", ret);
- return ret;
+ return PTR_ERR(trf->en_gpiod);
}
- trf->en2_gpio = of_get_named_gpio(np, "ti,enable-gpios", 1);
- if (!gpio_is_valid(trf->en2_gpio)) {
+ trf->en2_gpiod = devm_gpiod_get_index_optional(trf->dev, "ti,enable", 1,
+ GPIOD_OUT_LOW);
+ if (!trf->en2_gpiod) {
dev_info(trf->dev, "No EN2 GPIO property\n");
- } else {
- ret = devm_gpio_request_one(trf->dev, trf->en2_gpio,
- GPIOF_DIR_OUT | GPIOF_INIT_LOW, "trf7970a EN2");
- if (ret) {
- dev_err(trf->dev, "Can't request EN2 GPIO: %d\n", ret);
- return ret;
- }
-
- if (of_property_read_bool(np, "en2-rf-quirk"))
- trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;
+ } else if (IS_ERR(trf->en2_gpiod)) {
+ dev_err(trf->dev, "Error getting EN2 GPIO property: %ld\n",
+ PTR_ERR(trf->en2_gpiod));
+ return PTR_ERR(trf->en2_gpiod);
+ } else if (of_property_read_bool(np, "en2-rf-quirk")) {
+ trf->quirks |= TRF7970A_QUIRK_EN2_MUST_STAY_LOW;
}
of_property_read_u32(np, "clock-frequency", &clk_freq);
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 9/9] NFC: trf7970a: Clean up coding style issues
From: Mark Greer @ 2017-04-25 22:43 UTC (permalink / raw)
To: Samuel Ortiz
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
devicetree-u79uwXL29TY76Z2rM5mHXA, Mark Greer
In-Reply-To: <20170425224356.11498-1-mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
Clean up coding style issues according to scripts/Lindent.
Some scripts/Lindent changes were reverted when it appeared
to make the code less readable or when it made the line run
over 80 characters.
Signed-off-by: Mark Greer <mgreer-luAo+O/VEmrlveNOaEYElw@public.gmane.org>
---
drivers/nfc/trf7970a.c | 291 +++++++++++++++++++++++++------------------------
1 file changed, 147 insertions(+), 144 deletions(-)
diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
index bb777f50b4fb..28b942ea15fb 100644
--- a/drivers/nfc/trf7970a.c
+++ b/drivers/nfc/trf7970a.c
@@ -122,11 +122,10 @@
NFC_PROTO_ISO14443_B_MASK | NFC_PROTO_FELICA_MASK | \
NFC_PROTO_ISO15693_MASK | NFC_PROTO_NFC_DEP_MASK)
-#define TRF7970A_AUTOSUSPEND_DELAY 30000 /* 30 seconds */
+#define TRF7970A_AUTOSUSPEND_DELAY 30000 /* 30 seconds */
#define TRF7970A_13MHZ_CLOCK_FREQUENCY 13560000
#define TRF7970A_27MHZ_CLOCK_FREQUENCY 27120000
-
#define TRF7970A_RX_SKB_ALLOC_SIZE 256
#define TRF7970A_FIFO_SIZE 127
@@ -294,7 +293,7 @@
#define TRF7970A_REG_IO_CTRL_AUTO_REG BIT(7)
/* IRQ Status Register Bits */
-#define TRF7970A_IRQ_STATUS_NORESP BIT(0) /* ISO15693 only */
+#define TRF7970A_IRQ_STATUS_NORESP BIT(0) /* ISO15693 only */
#define TRF7970A_IRQ_STATUS_NFC_COL_ERROR BIT(0)
#define TRF7970A_IRQ_STATUS_COL BIT(1)
#define TRF7970A_IRQ_STATUS_FRAMING_EOF_ERROR BIT(2)
@@ -459,7 +458,6 @@ struct trf7970a {
struct delayed_work timeout_work;
};
-
static int trf7970a_cmd(struct trf7970a *trf, u8 opcode)
{
u8 cmd = TRF7970A_CMD_BIT_CTRL | TRF7970A_CMD_BIT_OPCODE(opcode);
@@ -470,7 +468,7 @@ static int trf7970a_cmd(struct trf7970a *trf, u8 opcode)
ret = spi_write(trf->spi, &cmd, 1);
if (ret)
dev_err(trf->dev, "%s - cmd: 0x%x, ret: %d\n", __func__, cmd,
- ret);
+ ret);
return ret;
}
@@ -482,14 +480,15 @@ static int trf7970a_read(struct trf7970a *trf, u8 reg, u8 *val)
ret = spi_write_then_read(trf->spi, &addr, 1, val, 1);
if (ret)
dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n", __func__, addr,
- ret);
+ ret);
dev_dbg(trf->dev, "read(0x%x): 0x%x\n", addr, *val);
return ret;
}
-static int trf7970a_read_cont(struct trf7970a *trf, u8 reg, u8 *buf, size_t len)
+static int trf7970a_read_cont(struct trf7970a *trf, u8 reg, u8 *buf,
+ size_t len)
{
u8 addr = reg | TRF7970A_CMD_BIT_RW | TRF7970A_CMD_BIT_CONTINUOUS;
struct spi_transfer t[2];
@@ -513,7 +512,7 @@ static int trf7970a_read_cont(struct trf7970a *trf, u8 reg, u8 *buf, size_t len)
ret = spi_sync(trf->spi, &m);
if (ret)
dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n", __func__, addr,
- ret);
+ ret);
return ret;
}
@@ -527,7 +526,7 @@ static int trf7970a_write(struct trf7970a *trf, u8 reg, u8 val)
ret = spi_write(trf->spi, buf, 2);
if (ret)
dev_err(trf->dev, "%s - write: 0x%x 0x%x, ret: %d\n", __func__,
- buf[0], buf[1], ret);
+ buf[0], buf[1], ret);
return ret;
}
@@ -549,7 +548,7 @@ static int trf7970a_read_irqstatus(struct trf7970a *trf, u8 *status)
if (ret)
dev_err(trf->dev, "%s - irqstatus: Status read failed: %d\n",
- __func__, ret);
+ __func__, ret);
else
*status = buf[0];
@@ -563,12 +562,12 @@ static int trf7970a_read_target_proto(struct trf7970a *trf, u8 *target_proto)
u8 addr;
addr = TRF79070A_NFC_TARGET_PROTOCOL | TRF7970A_CMD_BIT_RW |
- TRF7970A_CMD_BIT_CONTINUOUS;
+ TRF7970A_CMD_BIT_CONTINUOUS;
ret = spi_write_then_read(trf->spi, &addr, 1, buf, 2);
if (ret)
dev_err(trf->dev, "%s - target_proto: Read failed: %d\n",
- __func__, ret);
+ __func__, ret);
else
*target_proto = buf[0];
@@ -599,7 +598,7 @@ static int trf7970a_mode_detect(struct trf7970a *trf, u8 *rf_tech)
break;
default:
dev_dbg(trf->dev, "%s - mode_detect: target_proto: 0x%x\n",
- __func__, target_proto);
+ __func__, target_proto);
return -EIO;
}
@@ -615,8 +614,8 @@ static void trf7970a_send_upstream(struct trf7970a *trf)
if (trf->rx_skb && !IS_ERR(trf->rx_skb) && !trf->aborting)
print_hex_dump_debug("trf7970a rx data: ", DUMP_PREFIX_NONE,
- 16, 1, trf->rx_skb->data, trf->rx_skb->len,
- false);
+ 16, 1, trf->rx_skb->data, trf->rx_skb->len,
+ false);
trf->state = TRF7970A_ST_IDLE;
@@ -656,7 +655,8 @@ static void trf7970a_send_err_upstream(struct trf7970a *trf, int errno)
}
static int trf7970a_transmit(struct trf7970a *trf, struct sk_buff *skb,
- unsigned int len, u8 *prefix, unsigned int prefix_len)
+ unsigned int len, u8 *prefix,
+ unsigned int prefix_len)
{
struct spi_transfer t[2];
struct spi_message m;
@@ -664,7 +664,7 @@ static int trf7970a_transmit(struct trf7970a *trf, struct sk_buff *skb,
int ret;
print_hex_dump_debug("trf7970a tx data: ", DUMP_PREFIX_NONE,
- 16, 1, skb->data, len, false);
+ 16, 1, skb->data, len, false);
spi_message_init(&m);
@@ -681,7 +681,7 @@ static int trf7970a_transmit(struct trf7970a *trf, struct sk_buff *skb,
ret = spi_sync(trf->spi, &m);
if (ret) {
dev_err(trf->dev, "%s - Can't send tx data: %d\n", __func__,
- ret);
+ ret);
return ret;
}
@@ -705,7 +705,7 @@ static int trf7970a_transmit(struct trf7970a *trf, struct sk_buff *skb,
}
dev_dbg(trf->dev, "Setting timeout for %d ms, state: %d\n", timeout,
- trf->state);
+ trf->state);
schedule_delayed_work(&trf->timeout_work, msecs_to_jiffies(timeout));
@@ -773,9 +773,9 @@ static void trf7970a_drain_fifo(struct trf7970a *trf, u8 status)
if (fifo_bytes > skb_tailroom(skb)) {
skb = skb_copy_expand(skb, skb_headroom(skb),
- max_t(int, fifo_bytes,
- TRF7970A_RX_SKB_ALLOC_SIZE),
- GFP_KERNEL);
+ max_t(int, fifo_bytes,
+ TRF7970A_RX_SKB_ALLOC_SIZE),
+ GFP_KERNEL);
if (!skb) {
trf7970a_send_err_upstream(trf, -ENOMEM);
return;
@@ -786,7 +786,7 @@ static void trf7970a_drain_fifo(struct trf7970a *trf, u8 status)
}
ret = trf7970a_read_cont(trf, TRF7970A_FIFO_IO_REGISTER,
- skb_put(skb, fifo_bytes), fifo_bytes);
+ skb_put(skb, fifo_bytes), fifo_bytes);
if (ret) {
trf7970a_send_err_upstream(trf, ret);
return;
@@ -794,8 +794,7 @@ static void trf7970a_drain_fifo(struct trf7970a *trf, u8 status)
/* If received Type 2 ACK/NACK, shift right 4 bits and pass up */
if ((trf->framing == NFC_DIGITAL_FRAMING_NFCA_T2T) && (skb->len == 1) &&
- (trf->special_fcn_reg1 ==
- TRF7970A_SPECIAL_FCN_REG1_4_BIT_RX)) {
+ (trf->special_fcn_reg1 == TRF7970A_SPECIAL_FCN_REG1_4_BIT_RX)) {
skb->data[0] >>= 4;
status = TRF7970A_IRQ_STATUS_SRX;
} else {
@@ -818,16 +817,16 @@ static void trf7970a_drain_fifo(struct trf7970a *trf, u8 status)
}
no_rx_data:
- if (status == TRF7970A_IRQ_STATUS_SRX) { /* Receive complete */
+ if (status == TRF7970A_IRQ_STATUS_SRX) { /* Receive complete */
trf7970a_send_upstream(trf);
return;
}
dev_dbg(trf->dev, "Setting timeout for %d ms\n",
- TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT);
+ TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT);
schedule_delayed_work(&trf->timeout_work,
- msecs_to_jiffies(TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT));
+ msecs_to_jiffies(TRF7970A_WAIT_FOR_RX_DATA_TIMEOUT));
}
static irqreturn_t trf7970a_irq(int irq, void *dev_id)
@@ -850,7 +849,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
}
dev_dbg(trf->dev, "IRQ - state: %d, status: 0x%x\n", trf->state,
- status);
+ status);
if (!status) {
mutex_unlock(&trf->lock);
@@ -875,7 +874,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
case TRF7970A_ST_WAIT_FOR_TX_FIFO:
if (status & TRF7970A_IRQ_STATUS_TX) {
trf->ignore_timeout =
- !cancel_delayed_work(&trf->timeout_work);
+ !cancel_delayed_work(&trf->timeout_work);
trf7970a_fill_fifo(trf);
} else {
trf7970a_send_err_upstream(trf, -EIO);
@@ -885,11 +884,11 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
case TRF7970A_ST_WAIT_FOR_RX_DATA_CONT:
if (status & TRF7970A_IRQ_STATUS_SRX) {
trf->ignore_timeout =
- !cancel_delayed_work(&trf->timeout_work);
+ !cancel_delayed_work(&trf->timeout_work);
trf7970a_drain_fifo(trf, status);
} else if (status & TRF7970A_IRQ_STATUS_FIFO) {
ret = trf7970a_read(trf, TRF7970A_FIFO_STATUS,
- &fifo_bytes);
+ &fifo_bytes);
fifo_bytes &= ~TRF7970A_FIFO_STATUS_OVERFLOW;
@@ -898,14 +897,14 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
else if (!fifo_bytes)
trf7970a_cmd(trf, TRF7970A_CMD_FIFO_RESET);
} else if ((status == TRF7970A_IRQ_STATUS_TX) ||
- (!trf->is_initiator &&
- (status == (TRF7970A_IRQ_STATUS_TX |
- TRF7970A_IRQ_STATUS_NFC_RF)))) {
+ (!trf->is_initiator &&
+ (status == (TRF7970A_IRQ_STATUS_TX |
+ TRF7970A_IRQ_STATUS_NFC_RF)))) {
trf7970a_cmd(trf, TRF7970A_CMD_FIFO_RESET);
if (!trf->timeout) {
- trf->ignore_timeout = !cancel_delayed_work(
- &trf->timeout_work);
+ trf->ignore_timeout =
+ !cancel_delayed_work(&trf->timeout_work);
trf->rx_skb = ERR_PTR(0);
trf7970a_send_upstream(trf);
break;
@@ -929,13 +928,13 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
break;
case NFC_DIGITAL_FRAMING_NFCA_ANTICOL_COMPLETE:
ret = trf7970a_write(trf,
- TRF7970A_SPECIAL_FCN_REG1,
- TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL);
+ TRF7970A_SPECIAL_FCN_REG1,
+ TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL);
if (ret)
goto err_unlock_exit;
trf->special_fcn_reg1 =
- TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL;
+ TRF7970A_SPECIAL_FCN_REG1_14_ANTICOLL;
break;
default:
break;
@@ -943,7 +942,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
if (iso_ctrl != trf->iso_ctrl) {
ret = trf7970a_write(trf, TRF7970A_ISO_CTRL,
- iso_ctrl);
+ iso_ctrl);
if (ret)
goto err_unlock_exit;
@@ -960,7 +959,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
case TRF7970A_ST_LISTENING:
if (status & TRF7970A_IRQ_STATUS_SRX) {
trf->ignore_timeout =
- !cancel_delayed_work(&trf->timeout_work);
+ !cancel_delayed_work(&trf->timeout_work);
trf7970a_drain_fifo(trf, status);
} else if (!(status & TRF7970A_IRQ_STATUS_NFC_RF)) {
trf7970a_send_err_upstream(trf, -EIO);
@@ -969,7 +968,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
case TRF7970A_ST_LISTENING_MD:
if (status & TRF7970A_IRQ_STATUS_SRX) {
trf->ignore_timeout =
- !cancel_delayed_work(&trf->timeout_work);
+ !cancel_delayed_work(&trf->timeout_work);
ret = trf7970a_mode_detect(trf, &trf->md_rf_tech);
if (ret) {
@@ -984,7 +983,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id)
break;
default:
dev_err(trf->dev, "%s - Driver in invalid state: %d\n",
- __func__, trf->state);
+ __func__, trf->state);
}
err_unlock_exit:
@@ -1009,19 +1008,19 @@ static void trf7970a_issue_eof(struct trf7970a *trf)
trf->state = TRF7970A_ST_WAIT_FOR_RX_DATA;
dev_dbg(trf->dev, "Setting timeout for %d ms, state: %d\n",
- trf->timeout, trf->state);
+ trf->timeout, trf->state);
schedule_delayed_work(&trf->timeout_work,
- msecs_to_jiffies(trf->timeout));
+ msecs_to_jiffies(trf->timeout));
}
static void trf7970a_timeout_work_handler(struct work_struct *work)
{
struct trf7970a *trf = container_of(work, struct trf7970a,
- timeout_work.work);
+ timeout_work.work);
dev_dbg(trf->dev, "Timeout - state: %d, ignore_timeout: %d\n",
- trf->state, trf->ignore_timeout);
+ trf->state, trf->ignore_timeout);
mutex_lock(&trf->lock);
@@ -1052,7 +1051,7 @@ static int trf7970a_init(struct trf7970a *trf)
goto err_out;
ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL,
- trf->io_ctrl | TRF7970A_REG_IO_CTRL_VRS(0x1));
+ trf->io_ctrl | TRF7970A_REG_IO_CTRL_VRS(0x1));
if (ret)
goto err_out;
@@ -1065,13 +1064,13 @@ static int trf7970a_init(struct trf7970a *trf)
trf->chip_status_ctrl &= ~TRF7970A_CHIP_STATUS_RF_ON;
ret = trf7970a_write(trf, TRF7970A_MODULATOR_SYS_CLK_CTRL,
- trf->modulator_sys_clk_ctrl);
+ trf->modulator_sys_clk_ctrl);
if (ret)
goto err_out;
ret = trf7970a_write(trf, TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS,
- TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLH_96 |
- TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLL_32);
+ TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLH_96 |
+ TRF7970A_ADJUTABLE_FIFO_IRQ_LEVELS_WLL_32);
if (ret)
goto err_out;
@@ -1092,7 +1091,7 @@ static int trf7970a_init(struct trf7970a *trf)
static void trf7970a_switch_rf_off(struct trf7970a *trf)
{
if ((trf->state == TRF7970A_ST_PWR_OFF) ||
- (trf->state == TRF7970A_ST_RF_OFF))
+ (trf->state == TRF7970A_ST_RF_OFF))
return;
dev_dbg(trf->dev, "Switching rf off\n");
@@ -1116,9 +1115,9 @@ static int trf7970a_switch_rf_on(struct trf7970a *trf)
pm_runtime_get_sync(trf->dev);
- if (trf->state != TRF7970A_ST_RF_OFF) { /* Power on, RF off */
+ if (trf->state != TRF7970A_ST_RF_OFF) { /* Power on, RF off */
dev_err(trf->dev, "%s - Incorrect state: %d\n", __func__,
- trf->state);
+ trf->state);
return -EINVAL;
}
@@ -1153,7 +1152,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
break;
default:
dev_err(trf->dev, "%s - Invalid request: %d %d\n",
- __func__, trf->state, on);
+ __func__, trf->state, on);
trf7970a_switch_rf_off(trf);
ret = -EINVAL;
}
@@ -1164,7 +1163,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
break;
default:
dev_err(trf->dev, "%s - Invalid request: %d %d\n",
- __func__, trf->state, on);
+ __func__, trf->state, on);
ret = -EINVAL;
/* FALLTHROUGH */
case TRF7970A_ST_IDLE:
@@ -1189,36 +1188,36 @@ static int trf7970a_in_config_rf_tech(struct trf7970a *trf, int tech)
case NFC_DIGITAL_RF_TECH_106A:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_14443A_106;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_OOK;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_OOK;
trf->guard_time = TRF7970A_GUARD_TIME_NFCA;
break;
case NFC_DIGITAL_RF_TECH_106B:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_14443B_106;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_ASK10;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_ASK10;
trf->guard_time = TRF7970A_GUARD_TIME_NFCB;
break;
case NFC_DIGITAL_RF_TECH_212F:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_FELICA_212;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_ASK10;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_ASK10;
trf->guard_time = TRF7970A_GUARD_TIME_NFCF;
break;
case NFC_DIGITAL_RF_TECH_424F:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_FELICA_424;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_ASK10;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_ASK10;
trf->guard_time = TRF7970A_GUARD_TIME_NFCF;
break;
case NFC_DIGITAL_RF_TECH_ISO15693:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_15693_SGL_1OF4_2648;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_OOK;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_OOK;
trf->guard_time = TRF7970A_GUARD_TIME_15693;
break;
default:
@@ -1245,7 +1244,8 @@ static int trf7970a_is_rf_field(struct trf7970a *trf, bool *is_rf_field)
u8 rssi;
ret = trf7970a_write(trf, TRF7970A_CHIP_STATUS_CTRL,
- trf->chip_status_ctrl | TRF7970A_CHIP_STATUS_REC_ON);
+ trf->chip_status_ctrl |
+ TRF7970A_CHIP_STATUS_REC_ON);
if (ret)
return ret;
@@ -1260,7 +1260,7 @@ static int trf7970a_is_rf_field(struct trf7970a *trf, bool *is_rf_field)
return ret;
ret = trf7970a_write(trf, TRF7970A_CHIP_STATUS_CTRL,
- trf->chip_status_ctrl);
+ trf->chip_status_ctrl);
if (ret)
return ret;
@@ -1327,15 +1327,15 @@ static int trf7970a_in_config_framing(struct trf7970a *trf, int framing)
trf->iso_ctrl = iso_ctrl;
ret = trf7970a_write(trf, TRF7970A_MODULATOR_SYS_CLK_CTRL,
- trf->modulator_sys_clk_ctrl);
+ trf->modulator_sys_clk_ctrl);
if (ret)
return ret;
}
if (!(trf->chip_status_ctrl & TRF7970A_CHIP_STATUS_RF_ON)) {
ret = trf7970a_write(trf, TRF7970A_CHIP_STATUS_CTRL,
- trf->chip_status_ctrl |
- TRF7970A_CHIP_STATUS_RF_ON);
+ trf->chip_status_ctrl |
+ TRF7970A_CHIP_STATUS_RF_ON);
if (ret)
return ret;
@@ -1348,7 +1348,7 @@ static int trf7970a_in_config_framing(struct trf7970a *trf, int framing)
}
static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type,
- int param)
+ int param)
{
struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
int ret;
@@ -1360,7 +1360,7 @@ static int trf7970a_in_configure_hw(struct nfc_digital_dev *ddev, int type,
trf->is_initiator = true;
if ((trf->state == TRF7970A_ST_PWR_OFF) ||
- (trf->state == TRF7970A_ST_RF_OFF)) {
+ (trf->state == TRF7970A_ST_RF_OFF)) {
ret = trf7970a_switch_rf_on(trf);
if (ret)
goto err_unlock;
@@ -1418,7 +1418,7 @@ static int trf7970a_per_cmd_config(struct trf7970a *trf, struct sk_buff *skb)
* has to send an EOF in order to get a response.
*/
if ((trf->technology == NFC_DIGITAL_RF_TECH_106A) &&
- (trf->framing == NFC_DIGITAL_FRAMING_NFCA_T2T)) {
+ (trf->framing == NFC_DIGITAL_FRAMING_NFCA_T2T)) {
if (req[0] == NFC_T2T_CMD_READ)
special_fcn_reg1 = 0;
else
@@ -1426,7 +1426,7 @@ static int trf7970a_per_cmd_config(struct trf7970a *trf, struct sk_buff *skb)
if (special_fcn_reg1 != trf->special_fcn_reg1) {
ret = trf7970a_write(trf, TRF7970A_SPECIAL_FCN_REG1,
- special_fcn_reg1);
+ special_fcn_reg1);
if (ret)
return ret;
@@ -1446,7 +1446,7 @@ static int trf7970a_per_cmd_config(struct trf7970a *trf, struct sk_buff *skb)
iso_ctrl |= TRF7970A_ISO_CTRL_15693_SGL_1OF4_2648;
break;
case (ISO15693_REQ_FLAG_SUB_CARRIER |
- ISO15693_REQ_FLAG_DATA_RATE):
+ ISO15693_REQ_FLAG_DATA_RATE):
iso_ctrl |= TRF7970A_ISO_CTRL_15693_DBL_1OF4_2669;
break;
}
@@ -1461,10 +1461,10 @@ static int trf7970a_per_cmd_config(struct trf7970a *trf, struct sk_buff *skb)
if (trf->framing == NFC_DIGITAL_FRAMING_ISO15693_T5T) {
if (trf7970a_is_iso15693_write_or_lock(req[1]) &&
- (req[0] & ISO15693_REQ_FLAG_OPTION))
+ (req[0] & ISO15693_REQ_FLAG_OPTION))
trf->issue_eof = true;
else if ((trf->quirks &
- TRF7970A_QUIRK_T5T_RMB_EXTRA_BYTE) &&
+ TRF7970A_QUIRK_T5T_RMB_EXTRA_BYTE) &&
(req[1] == ISO15693_CMD_READ_MULTIPLE_BLOCK))
trf->adjust_resp_len = true;
}
@@ -1474,8 +1474,8 @@ static int trf7970a_per_cmd_config(struct trf7970a *trf, struct sk_buff *skb)
}
static int trf7970a_send_cmd(struct nfc_digital_dev *ddev,
- struct sk_buff *skb, u16 timeout,
- nfc_digital_cmd_complete_t cb, void *arg)
+ struct sk_buff *skb, u16 timeout,
+ nfc_digital_cmd_complete_t cb, void *arg)
{
struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
u8 prefix[5];
@@ -1484,7 +1484,7 @@ static int trf7970a_send_cmd(struct nfc_digital_dev *ddev,
u8 status;
dev_dbg(trf->dev, "New request - state: %d, timeout: %d ms, len: %d\n",
- trf->state, timeout, skb->len);
+ trf->state, timeout, skb->len);
if (skb->len > TRF7970A_TX_MAX)
return -EINVAL;
@@ -1492,9 +1492,9 @@ static int trf7970a_send_cmd(struct nfc_digital_dev *ddev,
mutex_lock(&trf->lock);
if ((trf->state != TRF7970A_ST_IDLE) &&
- (trf->state != TRF7970A_ST_IDLE_RX_BLOCKED)) {
+ (trf->state != TRF7970A_ST_IDLE_RX_BLOCKED)) {
dev_err(trf->dev, "%s - Bogus state: %d\n", __func__,
- trf->state);
+ trf->state);
ret = -EIO;
goto out_err;
}
@@ -1508,7 +1508,7 @@ static int trf7970a_send_cmd(struct nfc_digital_dev *ddev,
if (timeout) {
trf->rx_skb = nfc_alloc_recv_skb(TRF7970A_RX_SKB_ALLOC_SIZE,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!trf->rx_skb) {
dev_dbg(trf->dev, "Can't alloc rx_skb\n");
ret = -ENOMEM;
@@ -1545,14 +1545,14 @@ static int trf7970a_send_cmd(struct nfc_digital_dev *ddev,
* That totals 5 bytes.
*/
prefix[0] = TRF7970A_CMD_BIT_CTRL |
- TRF7970A_CMD_BIT_OPCODE(TRF7970A_CMD_FIFO_RESET);
+ TRF7970A_CMD_BIT_OPCODE(TRF7970A_CMD_FIFO_RESET);
prefix[1] = TRF7970A_CMD_BIT_CTRL |
- TRF7970A_CMD_BIT_OPCODE(trf->tx_cmd);
+ TRF7970A_CMD_BIT_OPCODE(trf->tx_cmd);
prefix[2] = TRF7970A_CMD_BIT_CONTINUOUS | TRF7970A_TX_LENGTH_BYTE1;
if (trf->framing == NFC_DIGITAL_FRAMING_NFCA_SHORT) {
prefix[3] = 0x00;
- prefix[4] = 0x0f; /* 7 bits */
+ prefix[4] = 0x0f; /* 7 bits */
} else {
prefix[3] = (len & 0xf00) >> 4;
prefix[3] |= ((len & 0xf0) >> 4);
@@ -1586,25 +1586,24 @@ static int trf7970a_tg_config_rf_tech(struct trf7970a *trf, int tech)
switch (tech) {
case NFC_DIGITAL_RF_TECH_106A:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_NFC_NFC_CE_MODE |
- TRF7970A_ISO_CTRL_NFC_CE |
- TRF7970A_ISO_CTRL_NFC_CE_14443A;
+ TRF7970A_ISO_CTRL_NFC_CE | TRF7970A_ISO_CTRL_NFC_CE_14443A;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_OOK;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_OOK;
break;
case NFC_DIGITAL_RF_TECH_212F:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_NFC_NFC_CE_MODE |
- TRF7970A_ISO_CTRL_NFC_NFCF_212;
+ TRF7970A_ISO_CTRL_NFC_NFCF_212;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_ASK10;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_ASK10;
break;
case NFC_DIGITAL_RF_TECH_424F:
trf->iso_ctrl_tech = TRF7970A_ISO_CTRL_NFC_NFC_CE_MODE |
- TRF7970A_ISO_CTRL_NFC_NFCF_424;
+ TRF7970A_ISO_CTRL_NFC_NFCF_424;
trf->modulator_sys_clk_ctrl =
- (trf->modulator_sys_clk_ctrl & 0xf8) |
- TRF7970A_MODULATOR_DEPTH_ASK10;
+ (trf->modulator_sys_clk_ctrl & 0xf8) |
+ TRF7970A_MODULATOR_DEPTH_ASK10;
break;
default:
dev_dbg(trf->dev, "Unsupported rf technology: %d\n", tech);
@@ -1621,9 +1620,9 @@ static int trf7970a_tg_config_rf_tech(struct trf7970a *trf, int tech)
* here.
*/
if ((trf->framing == NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED) &&
- (trf->iso_ctrl_tech != trf->iso_ctrl)) {
+ (trf->iso_ctrl_tech != trf->iso_ctrl)) {
ret = trf7970a_write(trf, TRF7970A_ISO_CTRL,
- trf->iso_ctrl_tech);
+ trf->iso_ctrl_tech);
trf->iso_ctrl = trf->iso_ctrl_tech;
}
@@ -1678,15 +1677,15 @@ static int trf7970a_tg_config_framing(struct trf7970a *trf, int framing)
trf->iso_ctrl = iso_ctrl;
ret = trf7970a_write(trf, TRF7970A_MODULATOR_SYS_CLK_CTRL,
- trf->modulator_sys_clk_ctrl);
+ trf->modulator_sys_clk_ctrl);
if (ret)
return ret;
}
if (!(trf->chip_status_ctrl & TRF7970A_CHIP_STATUS_RF_ON)) {
ret = trf7970a_write(trf, TRF7970A_CHIP_STATUS_CTRL,
- trf->chip_status_ctrl |
- TRF7970A_CHIP_STATUS_RF_ON);
+ trf->chip_status_ctrl |
+ TRF7970A_CHIP_STATUS_RF_ON);
if (ret)
return ret;
@@ -1697,7 +1696,7 @@ static int trf7970a_tg_config_framing(struct trf7970a *trf, int framing)
}
static int trf7970a_tg_configure_hw(struct nfc_digital_dev *ddev, int type,
- int param)
+ int param)
{
struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
int ret;
@@ -1709,7 +1708,7 @@ static int trf7970a_tg_configure_hw(struct nfc_digital_dev *ddev, int type,
trf->is_initiator = false;
if ((trf->state == TRF7970A_ST_PWR_OFF) ||
- (trf->state == TRF7970A_ST_RF_OFF)) {
+ (trf->state == TRF7970A_ST_RF_OFF)) {
ret = trf7970a_switch_rf_on(trf);
if (ret)
goto err_unlock;
@@ -1733,7 +1732,8 @@ static int trf7970a_tg_configure_hw(struct nfc_digital_dev *ddev, int type,
}
static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
- nfc_digital_cmd_complete_t cb, void *arg, bool mode_detect)
+ nfc_digital_cmd_complete_t cb, void *arg,
+ bool mode_detect)
{
struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
int ret;
@@ -1741,9 +1741,9 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
mutex_lock(&trf->lock);
if ((trf->state != TRF7970A_ST_IDLE) &&
- (trf->state != TRF7970A_ST_IDLE_RX_BLOCKED)) {
+ (trf->state != TRF7970A_ST_IDLE_RX_BLOCKED)) {
dev_err(trf->dev, "%s - Bogus state: %d\n", __func__,
- trf->state);
+ trf->state);
ret = -EIO;
goto out_err;
}
@@ -1756,7 +1756,7 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
}
trf->rx_skb = nfc_alloc_recv_skb(TRF7970A_RX_SKB_ALLOC_SIZE,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!trf->rx_skb) {
dev_dbg(trf->dev, "Can't alloc rx_skb\n");
ret = -ENOMEM;
@@ -1764,25 +1764,25 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
}
ret = trf7970a_write(trf, TRF7970A_RX_SPECIAL_SETTINGS,
- TRF7970A_RX_SPECIAL_SETTINGS_HBT |
- TRF7970A_RX_SPECIAL_SETTINGS_M848 |
- TRF7970A_RX_SPECIAL_SETTINGS_C424 |
- TRF7970A_RX_SPECIAL_SETTINGS_C212);
+ TRF7970A_RX_SPECIAL_SETTINGS_HBT |
+ TRF7970A_RX_SPECIAL_SETTINGS_M848 |
+ TRF7970A_RX_SPECIAL_SETTINGS_C424 |
+ TRF7970A_RX_SPECIAL_SETTINGS_C212);
if (ret)
goto out_err;
ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL,
- trf->io_ctrl | TRF7970A_REG_IO_CTRL_VRS(0x1));
+ trf->io_ctrl | TRF7970A_REG_IO_CTRL_VRS(0x1));
if (ret)
goto out_err;
ret = trf7970a_write(trf, TRF7970A_NFC_LOW_FIELD_LEVEL,
- TRF7970A_NFC_LOW_FIELD_LEVEL_RFDET(0x3));
+ TRF7970A_NFC_LOW_FIELD_LEVEL_RFDET(0x3));
if (ret)
goto out_err;
ret = trf7970a_write(trf, TRF7970A_NFC_TARGET_LEVEL,
- TRF7970A_NFC_TARGET_LEVEL_RFDET(0x7));
+ TRF7970A_NFC_TARGET_LEVEL_RFDET(0x7));
if (ret)
goto out_err;
@@ -1807,32 +1807,33 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
}
static int trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,
- nfc_digital_cmd_complete_t cb, void *arg)
+ nfc_digital_cmd_complete_t cb, void *arg)
{
struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
dev_dbg(trf->dev, "Listen - state: %d, timeout: %d ms\n",
- trf->state, timeout);
+ trf->state, timeout);
return _trf7970a_tg_listen(ddev, timeout, cb, arg, false);
}
static int trf7970a_tg_listen_md(struct nfc_digital_dev *ddev,
- u16 timeout, nfc_digital_cmd_complete_t cb, void *arg)
+ u16 timeout, nfc_digital_cmd_complete_t cb,
+ void *arg)
{
struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
int ret;
dev_dbg(trf->dev, "Listen MD - state: %d, timeout: %d ms\n",
- trf->state, timeout);
+ trf->state, timeout);
ret = trf7970a_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_RF_TECH,
- NFC_DIGITAL_RF_TECH_106A);
+ NFC_DIGITAL_RF_TECH_106A);
if (ret)
return ret;
ret = trf7970a_tg_configure_hw(ddev, NFC_DIGITAL_CONFIG_FRAMING,
- NFC_DIGITAL_FRAMING_NFCA_NFC_DEP);
+ NFC_DIGITAL_FRAMING_NFCA_NFC_DEP);
if (ret)
return ret;
@@ -1844,7 +1845,7 @@ static int trf7970a_tg_get_rf_tech(struct nfc_digital_dev *ddev, u8 *rf_tech)
struct trf7970a *trf = nfc_digital_get_drvdata(ddev);
dev_dbg(trf->dev, "Get RF Tech - state: %d, rf_tech: %d\n",
- trf->state, trf->md_rf_tech);
+ trf->state, trf->md_rf_tech);
*rf_tech = trf->md_rf_tech;
@@ -1933,20 +1934,19 @@ static int trf7970a_power_down(struct trf7970a *trf)
if (trf->state != TRF7970A_ST_RF_OFF) {
dev_dbg(trf->dev, "Can't power down - not RF_OFF state (%d)\n",
- trf->state);
+ trf->state);
return -EBUSY;
}
gpiod_set_value_cansleep(trf->en_gpiod, 0);
- if (trf->en2_gpiod &&
- !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW))
+ if (trf->en2_gpiod && !(trf->quirks & TRF7970A_QUIRK_EN2_MUST_STAY_LOW))
gpiod_set_value_cansleep(trf->en2_gpiod, 0);
ret = regulator_disable(trf->regulator);
if (ret)
dev_err(trf->dev, "%s - Can't disable VIN: %d\n", __func__,
- ret);
+ ret);
trf->state = TRF7970A_ST_PWR_OFF;
@@ -2060,16 +2060,16 @@ static int trf7970a_probe(struct spi_device *spi)
of_property_read_u32(np, "clock-frequency", &clk_freq);
if ((clk_freq != TRF7970A_27MHZ_CLOCK_FREQUENCY) ||
- (clk_freq != TRF7970A_13MHZ_CLOCK_FREQUENCY)) {
+ (clk_freq != TRF7970A_13MHZ_CLOCK_FREQUENCY)) {
dev_err(trf->dev,
- "clock-frequency (%u Hz) unsupported\n",
- clk_freq);
+ "clock-frequency (%u Hz) unsupported\n", clk_freq);
return -EINVAL;
}
ret = devm_request_threaded_irq(trf->dev, spi->irq, NULL,
- trf7970a_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- "trf7970a", trf);
+ trf7970a_irq,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ "trf7970a", trf);
if (ret) {
dev_err(trf->dev, "Can't request IRQ#%d: %d\n", spi->irq, ret);
return ret;
@@ -2114,9 +2114,10 @@ static int trf7970a_probe(struct spi_device *spi)
}
trf->ddev = nfc_digital_allocate_device(&trf7970a_nfc_ops,
- TRF7970A_SUPPORTED_PROTOCOLS,
- NFC_DIGITAL_DRV_CAPS_IN_CRC |
- NFC_DIGITAL_DRV_CAPS_TG_CRC, 0, 0);
+ TRF7970A_SUPPORTED_PROTOCOLS,
+ NFC_DIGITAL_DRV_CAPS_IN_CRC |
+ NFC_DIGITAL_DRV_CAPS_TG_CRC, 0,
+ 0);
if (!trf->ddev) {
dev_err(trf->dev, "Can't allocate NFC digital device\n");
ret = -ENOMEM;
@@ -2139,7 +2140,7 @@ static int trf7970a_probe(struct spi_device *spi)
ret = nfc_digital_register_device(trf->ddev);
if (ret) {
dev_err(trf->dev, "Can't register NFC digital device: %d\n",
- ret);
+ ret);
goto err_shutdown;
}
@@ -2248,29 +2249,31 @@ static int trf7970a_pm_runtime_resume(struct device *dev)
static const struct dev_pm_ops trf7970a_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(trf7970a_suspend, trf7970a_resume)
SET_RUNTIME_PM_OPS(trf7970a_pm_runtime_suspend,
- trf7970a_pm_runtime_resume, NULL)
+ trf7970a_pm_runtime_resume, NULL)
};
static const struct of_device_id trf7970a_of_match[] = {
- { .compatible = "ti,trf7970a", },
+ {.compatible = "ti,trf7970a",},
{},
};
+
MODULE_DEVICE_TABLE(of, trf7970a_of_match);
static const struct spi_device_id trf7970a_id_table[] = {
- { "trf7970a", 0 },
- { }
+ {"trf7970a", 0},
+ {}
};
+
MODULE_DEVICE_TABLE(spi, trf7970a_id_table);
static struct spi_driver trf7970a_spi_driver = {
.probe = trf7970a_probe,
.remove = trf7970a_remove,
.id_table = trf7970a_id_table,
- .driver = {
- .name = "trf7970a",
- .of_match_table = of_match_ptr(trf7970a_of_match),
- .pm = &trf7970a_pm_ops,
+ .driver = {
+ .name = "trf7970a",
+ .of_match_table = of_match_ptr(trf7970a_of_match),
+ .pm = &trf7970a_pm_ops,
},
};
--
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v2 1/2] net: dsa: b53: Add compatible strings for the Cygnus-family BCM11360.
From: Eric Anholt @ 2017-04-25 23:53 UTC (permalink / raw)
To: Florian Fainelli, Vivien Didelot, Andrew Lunn, netdev,
Rob Herring, Mark Rutland, devicetree
Cc: Scott Branden, Jon Mason, Ray Jui, linux-kernel, Eric Anholt,
bcm-kernel-feedback-list, linux-arm-kernel
Cygnus is a small family of SoCs, of which we currently have
devicetree for BCM11360 and BCM58300. The 11360's B53 is mostly the
same as 58xx, just requiring a tiny bit of setup that was previously
missing.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
v2: Reorder the entry in the docs (suggestion by Scott Branden), add
missing '"'
Documentation/devicetree/bindings/net/dsa/b53.txt | 3 +++
drivers/net/dsa/b53/b53_srab.c | 2 ++
2 files changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/dsa/b53.txt b/Documentation/devicetree/bindings/net/dsa/b53.txt
index d6c6e41648d4..eb679e92d525 100644
--- a/Documentation/devicetree/bindings/net/dsa/b53.txt
+++ b/Documentation/devicetree/bindings/net/dsa/b53.txt
@@ -13,6 +13,9 @@ Required properties:
"brcm,bcm5397"
"brcm,bcm5398"
+ For the BCM11360 SoC, must be:
+ "brcm,bcm11360-srab" and the mandatory "brcm,cygnus-srab" string
+
For the BCM5310x SoCs with an integrated switch, must be one of:
"brcm,bcm53010-srab"
"brcm,bcm53011-srab"
diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c
index 8a62b6a69703..c37ffd1b6833 100644
--- a/drivers/net/dsa/b53/b53_srab.c
+++ b/drivers/net/dsa/b53/b53_srab.c
@@ -364,6 +364,7 @@ static const struct of_device_id b53_srab_of_match[] = {
{ .compatible = "brcm,bcm53018-srab" },
{ .compatible = "brcm,bcm53019-srab" },
{ .compatible = "brcm,bcm5301x-srab" },
+ { .compatible = "brcm,bcm11360-srab", .data = (void *)BCM58XX_DEVICE_ID },
{ .compatible = "brcm,bcm58522-srab", .data = (void *)BCM58XX_DEVICE_ID },
{ .compatible = "brcm,bcm58525-srab", .data = (void *)BCM58XX_DEVICE_ID },
{ .compatible = "brcm,bcm58535-srab", .data = (void *)BCM58XX_DEVICE_ID },
@@ -371,6 +372,7 @@ static const struct of_device_id b53_srab_of_match[] = {
{ .compatible = "brcm,bcm58623-srab", .data = (void *)BCM58XX_DEVICE_ID },
{ .compatible = "brcm,bcm58625-srab", .data = (void *)BCM58XX_DEVICE_ID },
{ .compatible = "brcm,bcm88312-srab", .data = (void *)BCM58XX_DEVICE_ID },
+ { .compatible = "brcm,cygnus-srab", .data = (void *)BCM58XX_DEVICE_ID },
{ .compatible = "brcm,nsp-srab", .data = (void *)BCM58XX_DEVICE_ID },
{ /* sentinel */ },
};
--
2.11.0
^ permalink raw reply related
* [PATCH v2 2/2] ARM: dts: Add the ethernet and ethernet PHY to the cygnus core DT.
From: Eric Anholt @ 2017-04-25 23:53 UTC (permalink / raw)
To: Florian Fainelli, Vivien Didelot, Andrew Lunn, netdev,
Rob Herring, Mark Rutland, devicetree
Cc: linux-arm-kernel, linux-kernel, bcm-kernel-feedback-list, Ray Jui,
Scott Branden, Jon Mason, Eric Anholt
In-Reply-To: <20170425235357.7690-1-eric@anholt.net>
Cygnus has a single AMAC controller connected to the B53 switch with 2
PHYs. On the BCM911360_EP platform, those two PHYs are connected to
the external ethernet jacks.
Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
v2: Call the node "switch", just call the ports "port" (suggestions by
Florian), drop max-speed on the phys (suggestion by Andrew Lunn),
call the other nodes "ethernet" and "ethernet-phy" (suggestions by
Sergei Shtylyov)
arch/arm/boot/dts/bcm-cygnus.dtsi | 58 ++++++++++++++++++++++++++++++++++
arch/arm/boot/dts/bcm911360_entphn.dts | 8 +++++
2 files changed, 66 insertions(+)
diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi b/arch/arm/boot/dts/bcm-cygnus.dtsi
index 009f1346b817..9fd89be0f5e0 100644
--- a/arch/arm/boot/dts/bcm-cygnus.dtsi
+++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
@@ -142,6 +142,54 @@
interrupts = <0>;
};
+ mdio: mdio@18002000 {
+ compatible = "brcm,iproc-mdio";
+ reg = <0x18002000 0x8>;
+ #size-cells = <1>;
+ #address-cells = <0>;
+
+ gphy0: ethernet-phy@0 {
+ reg = <0>;
+ };
+
+ gphy1: ethernet-phy@1 {
+ reg = <1>;
+ };
+ };
+
+ switch: switch@18007000 {
+ compatible = "brcm,bcm11360-srab", "brcm,cygnus-srab";
+ reg = <0x18007000 0x1000>;
+ status = "disabled";
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ phy-handle = <&gphy0>;
+ phy-mode = "rgmii";
+ };
+
+ port@1 {
+ reg = <1>;
+ phy-handle = <&gphy1>;
+ phy-mode = "rgmii";
+ };
+
+ port@8 {
+ reg = <8>;
+ label = "cpu";
+ ethernet = <ð0>;
+ fixed-link {
+ speed = <1000>;
+ full-duplex;
+ };
+ };
+ };
+ };
+
i2c0: i2c@18008000 {
compatible = "brcm,cygnus-iproc-i2c", "brcm,iproc-i2c";
reg = <0x18008000 0x100>;
@@ -295,6 +343,16 @@
status = "disabled";
};
+ eth0: ethernet@18042000 {
+ compatible = "brcm,amac";
+ reg = <0x18042000 0x1000>,
+ <0x18110000 0x1000>;
+ reg-names = "amac_base", "idm_base";
+ interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
+ max-speed = <1000>;
+ status = "disabled";
+ };
+
nand: nand@18046000 {
compatible = "brcm,nand-iproc", "brcm,brcmnand-v6.1";
reg = <0x18046000 0x600>, <0xf8105408 0x600>,
diff --git a/arch/arm/boot/dts/bcm911360_entphn.dts b/arch/arm/boot/dts/bcm911360_entphn.dts
index 8b3800f46288..e037dea63f4a 100644
--- a/arch/arm/boot/dts/bcm911360_entphn.dts
+++ b/arch/arm/boot/dts/bcm911360_entphn.dts
@@ -57,6 +57,14 @@
};
};
+ð0 {
+ status = "okay";
+};
+
+&switch {
+ status = "okay";
+};
+
&uart3 {
status = "okay";
};
--
2.11.0
^ permalink raw reply related
* Re: [PATCH v2 2/2] ARM: dts: Add the ethernet and ethernet PHY to the cygnus core DT.
From: Florian Fainelli @ 2017-04-25 23:59 UTC (permalink / raw)
To: Eric Anholt, Vivien Didelot, Andrew Lunn,
netdev-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Mark Rutland,
devicetree-u79uwXL29TY76Z2rM5mHXA
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w, Ray Jui,
Scott Branden, Jon Mason
In-Reply-To: <20170425235357.7690-2-eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
On 04/25/2017 04:53 PM, Eric Anholt wrote:
> Cygnus has a single AMAC controller connected to the B53 switch with 2
> PHYs. On the BCM911360_EP platform, those two PHYs are connected to
> the external ethernet jacks.
>
> Signed-off-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
> Reviewed-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>
> v2: Call the node "switch", just call the ports "port" (suggestions by
> Florian), drop max-speed on the phys (suggestion by Andrew Lunn),
> call the other nodes "ethernet" and "ethernet-phy" (suggestions by
> Sergei Shtylyov)
>
> arch/arm/boot/dts/bcm-cygnus.dtsi | 58 ++++++++++++++++++++++++++++++++++
> arch/arm/boot/dts/bcm911360_entphn.dts | 8 +++++
> 2 files changed, 66 insertions(+)
>
> diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi b/arch/arm/boot/dts/bcm-cygnus.dtsi
> index 009f1346b817..9fd89be0f5e0 100644
> --- a/arch/arm/boot/dts/bcm-cygnus.dtsi
> +++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
> @@ -142,6 +142,54 @@
> interrupts = <0>;
> };
>
> + mdio: mdio@18002000 {
> + compatible = "brcm,iproc-mdio";
> + reg = <0x18002000 0x8>;
> + #size-cells = <1>;
> + #address-cells = <0>;
Sorry for not noticing earlier, since you override this correctly in the
board-level DTS file can you put a:
status = "disabled"
property in there by default?
Thanks!
> +
> + gphy0: ethernet-phy@0 {
> + reg = <0>;
> + };
> +
> + gphy1: ethernet-phy@1 {
> + reg = <1>;
> + };
> + };
> +
> + switch: switch@18007000 {
> + compatible = "brcm,bcm11360-srab", "brcm,cygnus-srab";
> + reg = <0x18007000 0x1000>;
> + status = "disabled";
> +
> + ports {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + port@0 {
> + reg = <0>;
> + phy-handle = <&gphy0>;
> + phy-mode = "rgmii";
> + };
> +
> + port@1 {
> + reg = <1>;
> + phy-handle = <&gphy1>;
> + phy-mode = "rgmii";
> + };
> +
> + port@8 {
> + reg = <8>;
> + label = "cpu";
> + ethernet = <ð0>;
> + fixed-link {
> + speed = <1000>;
> + full-duplex;
> + };
> + };
> + };
> + };
> +
> i2c0: i2c@18008000 {
> compatible = "brcm,cygnus-iproc-i2c", "brcm,iproc-i2c";
> reg = <0x18008000 0x100>;
> @@ -295,6 +343,16 @@
> status = "disabled";
> };
>
> + eth0: ethernet@18042000 {
> + compatible = "brcm,amac";
> + reg = <0x18042000 0x1000>,
> + <0x18110000 0x1000>;
> + reg-names = "amac_base", "idm_base";
> + interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
> + max-speed = <1000>;
> + status = "disabled";
> + };
> +
> nand: nand@18046000 {
> compatible = "brcm,nand-iproc", "brcm,brcmnand-v6.1";
> reg = <0x18046000 0x600>, <0xf8105408 0x600>,
> diff --git a/arch/arm/boot/dts/bcm911360_entphn.dts b/arch/arm/boot/dts/bcm911360_entphn.dts
> index 8b3800f46288..e037dea63f4a 100644
> --- a/arch/arm/boot/dts/bcm911360_entphn.dts
> +++ b/arch/arm/boot/dts/bcm911360_entphn.dts
> @@ -57,6 +57,14 @@
> };
> };
>
> +ð0 {
> + status = "okay";
> +};
> +
> +&switch {
> + status = "okay";
> +};
> +
> &uart3 {
> status = "okay";
> };
>
--
Florian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH v4 0/2] of: Add unit tests for applying overlays
From: frowand.list @ 2017-04-26 0:09 UTC (permalink / raw)
To: Rob Herring, stephen.boyd, mmarek; +Cc: devicetree, linux-kernel, linux-kbuild
From: Frank Rowand <frank.rowand@sony.com>
Existing overlay unit tests examine individual pieces of the overlay code.
The new tests target the entire process of applying an overlay.
Changes from v3:
- make subject line of patch 1 more generic
Changes from v2:
- of_private.h: move __unflatten_device_tree() outside
#ifdef CONFIG_OF_UNITTEST
- unittest.c: move overlay declaration macros outside
#ifdef CONFIG_OF_OVERLAY
- unittest.c: make overlay_info overlays[] static
- unittest.c: remove extra blank line
Changes from v1:
- Move overlay base dtb unflattening into unittest.c. Call from fdt.c.
- Clarify file and variable names, 'overlay_test_' instead of 'ot_'
- Use proper naming convention for node names.
- A few added comments.
- Improve error messages in the new tests.
Frank Rowand (2):
of: support dtc compiler flags for overlays
of: Add unit tests for applying overlays
drivers/of/fdt.c | 14 +-
drivers/of/of_private.h | 12 +
drivers/of/unittest-data/Makefile | 17 +-
drivers/of/unittest-data/overlay.dts | 53 ++++
drivers/of/unittest-data/overlay_bad_phandle.dts | 20 ++
drivers/of/unittest-data/overlay_base.dts | 80 ++++++
drivers/of/unittest.c | 317 +++++++++++++++++++++++
scripts/Makefile.lib | 2 +
8 files changed, 507 insertions(+), 8 deletions(-)
create mode 100644 drivers/of/unittest-data/overlay.dts
create mode 100644 drivers/of/unittest-data/overlay_bad_phandle.dts
create mode 100644 drivers/of/unittest-data/overlay_base.dts
--
Frank Rowand <frank.rowand@sony.com>
^ permalink raw reply
* [PATCH v4 1/2] of: per-file dtc compiler flags
From: frowand.list-Re5JQEeQqe8AvxtiuMwx3w @ 2017-04-26 0:09 UTC (permalink / raw)
To: Rob Herring, stephen.boyd-QSEj5FYQhm4dnm+yROfE0A,
mmarek-IBi9RG/b67k
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-kbuild-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1493165394-29367-1-git-send-email-frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
The dtc compiler version that adds initial support was available
in 4.11-rc1. Add the ability to set an additional dtc compiler
flag is needed by overlays.
Signed-off-by: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
---
scripts/Makefile.lib | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0a07f9014944..0bbec480d323 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -283,6 +283,8 @@ ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
DTC_FLAGS += -Wno-unit_address_vs_reg
endif
+DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
+
# Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_S_dtb= DTB $@
cmd_dt_S_dtb= \
--
Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v4 2/2] of: Add unit tests for applying overlays
From: frowand.list @ 2017-04-26 0:09 UTC (permalink / raw)
To: Rob Herring, stephen.boyd, mmarek; +Cc: devicetree, linux-kernel, linux-kbuild
In-Reply-To: <1493165394-29367-1-git-send-email-frowand.list@gmail.com>
From: Frank Rowand <frank.rowand@sony.com>
Existing overlay unit tests examine individual pieces of the overlay
code. The new tests target the entire process of applying an overlay.
Signed-off-by: Frank Rowand <frank.rowand@sony.com>
---
There are checkpatch warnings. I have reviewed them and feel they
can be ignored.
drivers/of/fdt.c | 14 +-
drivers/of/of_private.h | 12 +
drivers/of/unittest-data/Makefile | 17 +-
drivers/of/unittest-data/overlay.dts | 53 ++++
drivers/of/unittest-data/overlay_bad_phandle.dts | 20 ++
drivers/of/unittest-data/overlay_base.dts | 80 ++++++
drivers/of/unittest.c | 317 +++++++++++++++++++++++
7 files changed, 505 insertions(+), 8 deletions(-)
create mode 100644 drivers/of/unittest-data/overlay.dts
create mode 100644 drivers/of/unittest-data/overlay_bad_phandle.dts
create mode 100644 drivers/of/unittest-data/overlay_base.dts
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e5ce4b59e162..e33f7818bc6c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -31,6 +31,8 @@
#include <asm/setup.h> /* for COMMAND_LINE_SIZE */
#include <asm/page.h>
+#include "of_private.h"
+
/*
* of_fdt_limit_memory - limit the number of regions in the /memory node
* @limit: maximum entries
@@ -469,11 +471,11 @@ static int unflatten_dt_nodes(const void *blob,
* Returns NULL on failure or the memory chunk containing the unflattened
* device tree on success.
*/
-static void *__unflatten_device_tree(const void *blob,
- struct device_node *dad,
- struct device_node **mynodes,
- void *(*dt_alloc)(u64 size, u64 align),
- bool detached)
+void *__unflatten_device_tree(const void *blob,
+ struct device_node *dad,
+ struct device_node **mynodes,
+ void *(*dt_alloc)(u64 size, u64 align),
+ bool detached)
{
int size;
void *mem;
@@ -1261,6 +1263,8 @@ void __init unflatten_device_tree(void)
/* Get pointer to "/chosen" and "/aliases" nodes for use everywhere */
of_alias_scan(early_init_dt_alloc_memory_arch);
+
+ unittest_unflatten_overlay_base();
}
/**
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 18bbb4517e25..de5c604f5cc4 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -55,6 +55,18 @@ static inline int of_property_notify(int action, struct device_node *np,
}
#endif /* CONFIG_OF_DYNAMIC */
+#ifdef CONFIG_OF_UNITTEST
+extern void __init unittest_unflatten_overlay_base(void);
+#else
+static inline void unittest_unflatten_overlay_base(void) {};
+#endif
+
+extern void *__unflatten_device_tree(const void *blob,
+ struct device_node *dad,
+ struct device_node **mynodes,
+ void *(*dt_alloc)(u64 size, u64 align),
+ bool detached);
+
/**
* General utilities for working with live trees.
*
diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile
index 1ac5cc01d627..6e00a9c69e58 100644
--- a/drivers/of/unittest-data/Makefile
+++ b/drivers/of/unittest-data/Makefile
@@ -1,7 +1,18 @@
obj-y += testcases.dtb.o
+obj-y += overlay.dtb.o
+obj-y += overlay_bad_phandle.dtb.o
+obj-y += overlay_base.dtb.o
targets += testcases.dtb testcases.dtb.S
+targets += overlay.dtb overlay.dtb.S
+targets += overlay_bad_phandle.dtb overlay_bad_phandle.dtb.S
+targets += overlay_base.dtb overlay_base.dtb.S
-.SECONDARY: \
- $(obj)/testcases.dtb.S \
- $(obj)/testcases.dtb
+.PRECIOUS: \
+ $(obj)/%.dtb.S \
+ $(obj)/%.dtb
+
+# enable creation of __symbols__ node
+DTC_FLAGS_overlay := -@
+DTC_FLAGS_overlay_bad_phandle := -@
+DTC_FLAGS_overlay_base := -@
diff --git a/drivers/of/unittest-data/overlay.dts b/drivers/of/unittest-data/overlay.dts
new file mode 100644
index 000000000000..6cd7e6a0c13e
--- /dev/null
+++ b/drivers/of/unittest-data/overlay.dts
@@ -0,0 +1,53 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+
+ fragment@0 {
+ target = <&electric_1>;
+
+ __overlay__ {
+ status = "ok";
+
+ hvac_2: hvac-large-1 {
+ compatible = "ot,hvac-large";
+ heat-range = < 40 75 >;
+ cool-range = < 65 80 >;
+ };
+ };
+ };
+
+ fragment@1 {
+ target = <&rides_1>;
+
+ __overlay__ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ status = "ok";
+
+ ride@200 {
+ compatible = "ot,ferris-wheel";
+ reg = < 0x00000200 0x100 >;
+ hvac-provider = < &hvac_2 >;
+ hvac-thermostat = < 27 32 > ;
+ hvac-zones = < 12 5 >;
+ hvac-zone-names = "operator", "snack-bar";
+ spin-controller = < &spin_ctrl_1 3 >;
+ spin-rph = < 30 >;
+ gondolas = < 16 >;
+ gondola-capacity = < 6 >;
+ };
+ };
+ };
+
+ fragment@2 {
+ target = <&lights_2>;
+
+ __overlay__ {
+ status = "ok";
+ color = "purple", "white", "red", "green";
+ rate = < 3 256 >;
+ };
+ };
+
+};
diff --git a/drivers/of/unittest-data/overlay_bad_phandle.dts b/drivers/of/unittest-data/overlay_bad_phandle.dts
new file mode 100644
index 000000000000..270ee885a623
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_bad_phandle.dts
@@ -0,0 +1,20 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+
+ fragment@0 {
+ target = <&electric_1>;
+
+ __overlay__ {
+
+ // This label should cause an error when the overlay
+ // is applied. There is already a phandle value
+ // in the base tree for motor-1.
+ spin_ctrl_1_conflict: motor-1 {
+ accelerate = < 3 >;
+ decelerate = < 5 >;
+ };
+ };
+ };
+};
diff --git a/drivers/of/unittest-data/overlay_base.dts b/drivers/of/unittest-data/overlay_base.dts
new file mode 100644
index 000000000000..5566b27fb61a
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_base.dts
@@ -0,0 +1,80 @@
+/dts-v1/;
+/plugin/;
+
+/*
+ * Base device tree that overlays will be applied against.
+ *
+ * Do not add any properties in node "/".
+ * Do not add any nodes other than "/testcase-data-2" in node "/".
+ * Do not add anything that would result in dtc creating node "/__fixups__".
+ * dtc will create nodes "/__symbols__" and "/__local_fixups__".
+ */
+
+/ {
+ testcase-data-2 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ electric_1: substation@100 {
+ compatible = "ot,big-volts-control";
+ reg = < 0x00000100 0x100 >;
+ status = "disabled";
+
+ hvac_1: hvac-medium-1 {
+ compatible = "ot,hvac-medium";
+ heat-range = < 50 75 >;
+ cool-range = < 60 80 >;
+ };
+
+ spin_ctrl_1: motor-1 {
+ compatible = "ot,ferris-wheel-motor";
+ spin = "clockwise";
+ };
+
+ spin_ctrl_2: motor-8 {
+ compatible = "ot,roller-coaster-motor";
+ };
+ };
+
+ rides_1: fairway-1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "ot,rides";
+ status = "disabled";
+ orientation = < 127 >;
+
+ ride@100 {
+ compatible = "ot,roller-coaster";
+ reg = < 0x00000100 0x100 >;
+ hvac-provider = < &hvac_1 >;
+ hvac-thermostat = < 29 > ;
+ hvac-zones = < 14 >;
+ hvac-zone-names = "operator";
+ spin-controller = < &spin_ctrl_2 5 &spin_ctrl_2 7 >;
+ spin-controller-names = "track_1", "track_2";
+ queues = < 2 >;
+ };
+ };
+
+ lights_1: lights@30000 {
+ compatible = "ot,work-lights";
+ reg = < 0x00030000 0x1000 >;
+ status = "disabled";
+ };
+
+ lights_2: lights@40000 {
+ compatible = "ot,show-lights";
+ reg = < 0x00040000 0x1000 >;
+ status = "disabled";
+ rate = < 13 138 >;
+ };
+
+ retail_1: vending@50000 {
+ reg = < 0x00050000 0x1000 >;
+ compatible = "ot,tickets";
+ status = "disabled";
+ };
+
+ };
+};
+
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 62db55b97c10..12597ff8cfb0 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -8,6 +8,7 @@
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/hashtable.h>
+#include <linux/libfdt.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/of_irq.h>
@@ -1925,6 +1926,320 @@ static void __init of_unittest_overlay(void)
static inline void __init of_unittest_overlay(void) { }
#endif
+/*
+ * __dtb_ot_begin[] and __dtb_ot_end[] are created by cmd_dt_S_dtb
+ * in scripts/Makefile.lib
+ */
+
+#define OVERLAY_INFO_EXTERN(name) \
+ extern uint8_t __dtb_##name##_begin[]; \
+ extern uint8_t __dtb_##name##_end[]
+
+#define OVERLAY_INFO(name, expected) \
+{ .dtb_begin = __dtb_##name##_begin, \
+ .dtb_end = __dtb_##name##_end, \
+ .expected_result = expected, \
+}
+
+struct overlay_info {
+ uint8_t *dtb_begin;
+ uint8_t *dtb_end;
+ void *data;
+ struct device_node *np_overlay;
+ int expected_result;
+ int overlay_id;
+};
+
+OVERLAY_INFO_EXTERN(overlay_base);
+OVERLAY_INFO_EXTERN(overlay);
+OVERLAY_INFO_EXTERN(overlay_bad_phandle);
+
+#ifdef CONFIG_OF_OVERLAY
+
+/* order of entries is hard-coded into users of overlays[] */
+static struct overlay_info overlays[] = {
+ OVERLAY_INFO(overlay_base, -9999),
+ OVERLAY_INFO(overlay, 0),
+ OVERLAY_INFO(overlay_bad_phandle, -EINVAL),
+ {}
+};
+
+static struct device_node *overlay_base_root;
+
+/*
+ * Create base device tree for the overlay unittest.
+ *
+ * This is called from very early boot code.
+ *
+ * Do as much as possible the same way as done in __unflatten_device_tree
+ * and other early boot steps for the normal FDT so that the overlay base
+ * unflattened tree will have the same characteristics as the real tree
+ * (such as having memory allocated by the early allocator). The goal
+ * is to test "the real thing" as much as possible, and test "test setup
+ * code" as little as possible.
+ *
+ * Have to stop before resolving phandles, because that uses kmalloc.
+ */
+void __init unittest_unflatten_overlay_base(void)
+{
+ struct overlay_info *info;
+ u32 data_size;
+ u32 size;
+
+ info = &overlays[0];
+
+ if (info->expected_result != -9999) {
+ pr_err("No dtb 'overlay_base' to attach\n");
+ return;
+ }
+
+ data_size = info->dtb_end - info->dtb_begin;
+ if (!data_size) {
+ pr_err("No dtb 'overlay_base' to attach\n");
+ return;
+ }
+
+ size = fdt_totalsize(info->dtb_begin);
+ if (size != data_size) {
+ pr_err("dtb 'overlay_base' header totalsize != actual size");
+ return;
+ }
+
+ info->data = early_init_dt_alloc_memory_arch(size,
+ roundup_pow_of_two(FDT_V17_SIZE));
+ if (!info->data) {
+ pr_err("alloc for dtb 'overlay_base' failed");
+ return;
+ }
+
+ memcpy(info->data, info->dtb_begin, size);
+
+ __unflatten_device_tree(info->data, NULL, &info->np_overlay,
+ early_init_dt_alloc_memory_arch, true);
+ overlay_base_root = info->np_overlay;
+}
+
+/*
+ * The purpose of of_unittest_overlay_data_add is to add an
+ * overlay in the normal fashion. This is a test of the whole
+ * picture, instead of testing individual elements.
+ *
+ * A secondary purpose is to be able to verify that the contents of
+ * /proc/device-tree/ contains the updated structure and values from
+ * the overlay. That must be verified separately in user space.
+ *
+ * Return 0 on unexpected error.
+ */
+static int __init overlay_data_add(int onum)
+{
+ struct overlay_info *info;
+ int k;
+ int ret;
+ u32 size;
+ u32 size_from_header;
+
+ for (k = 0, info = overlays; info; info++, k++) {
+ if (k == onum)
+ break;
+ }
+ if (onum > k)
+ return 0;
+
+ size = info->dtb_end - info->dtb_begin;
+ if (!size) {
+ pr_err("no overlay to attach, %d\n", onum);
+ ret = 0;
+ }
+
+ size_from_header = fdt_totalsize(info->dtb_begin);
+ if (size_from_header != size) {
+ pr_err("overlay header totalsize != actual size, %d", onum);
+ return 0;
+ }
+
+ /*
+ * Must create permanent copy of FDT because of_fdt_unflatten_tree()
+ * will create pointers to the passed in FDT in the EDT.
+ */
+ info->data = kmemdup(info->dtb_begin, size, GFP_KERNEL);
+ if (!info->data) {
+ pr_err("unable to allocate memory for data, %d\n", onum);
+ return 0;
+ }
+
+ of_fdt_unflatten_tree(info->data, NULL, &info->np_overlay);
+ if (!info->np_overlay) {
+ pr_err("unable to unflatten overlay, %d\n", onum);
+ ret = 0;
+ goto out_free_data;
+ }
+ of_node_set_flag(info->np_overlay, OF_DETACHED);
+
+ ret = of_resolve_phandles(info->np_overlay);
+ if (ret) {
+ pr_err("resolve ot phandles (ret=%d), %d\n", ret, onum);
+ goto out_free_np_overlay;
+ }
+
+ ret = of_overlay_create(info->np_overlay);
+ if (ret < 0) {
+ pr_err("of_overlay_create() (ret=%d), %d\n", ret, onum);
+ goto out_free_np_overlay;
+ } else {
+ info->overlay_id = ret;
+ ret = 0;
+ }
+
+ pr_debug("__dtb_overlay_begin applied, overlay id %d\n", ret);
+
+ goto out;
+
+out_free_np_overlay:
+ /*
+ * info->np_overlay is the unflattened device tree
+ * It has not been spliced into the live tree.
+ */
+
+ /* todo: function to free unflattened device tree */
+
+out_free_data:
+ kfree(info->data);
+
+out:
+ return (ret == info->expected_result);
+}
+
+/*
+ * The purpose of of_unittest_overlay_high_level is to add an overlay
+ * in the normal fashion. This is a test of the whole picture,
+ * instead of individual elements.
+ *
+ * The first part of the function is _not_ normal overlay usage; it is
+ * finishing splicing the base overlay device tree into the live tree.
+ */
+static __init void of_unittest_overlay_high_level(void)
+{
+ struct device_node *last_sibling;
+ struct device_node *np;
+ struct device_node *of_symbols;
+ struct device_node *overlay_base_symbols;
+ struct device_node **pprev;
+ struct property *prop;
+ int ret;
+
+ if (!overlay_base_root) {
+ unittest(0, "overlay_base_root not initialized\n");
+ return;
+ }
+
+ /*
+ * Could not fixup phandles in unittest_unflatten_overlay_base()
+ * because kmalloc() was not yet available.
+ */
+ of_resolve_phandles(overlay_base_root);
+
+ /*
+ * do not allow overlay_base to duplicate any node already in
+ * tree, this greatly simplifies the code
+ */
+
+ /*
+ * remove overlay_base_root node "__local_fixups", after
+ * being used by of_resolve_phandles()
+ */
+ pprev = &overlay_base_root->child;
+ for (np = overlay_base_root->child; np; np = np->sibling) {
+ if (!of_node_cmp(np->name, "__local_fixups__")) {
+ *pprev = np->sibling;
+ break;
+ }
+ pprev = &np->sibling;
+ }
+
+ /* remove overlay_base_root node "__symbols__" if in live tree */
+ of_symbols = of_get_child_by_name(of_root, "__symbols__");
+ if (of_symbols) {
+ /* will have to graft properties from node into live tree */
+ pprev = &overlay_base_root->child;
+ for (np = overlay_base_root->child; np; np = np->sibling) {
+ if (!of_node_cmp(np->name, "__symbols__")) {
+ overlay_base_symbols = np;
+ *pprev = np->sibling;
+ break;
+ }
+ pprev = &np->sibling;
+ }
+ }
+
+ for (np = overlay_base_root->child; np; np = np->sibling) {
+ if (of_get_child_by_name(of_root, np->name)) {
+ unittest(0, "illegal node name in overlay_base %s",
+ np->name);
+ return;
+ }
+ }
+
+ /*
+ * overlay 'overlay_base' is not allowed to have root
+ * properties, so only need to splice nodes into main device tree.
+ *
+ * root node of *overlay_base_root will not be freed, it is lost
+ * memory.
+ */
+
+ for (np = overlay_base_root->child; np; np = np->sibling)
+ np->parent = of_root;
+
+ mutex_lock(&of_mutex);
+
+ for (np = of_root->child; np; np = np->sibling)
+ last_sibling = np;
+
+ if (last_sibling)
+ last_sibling->sibling = overlay_base_root->child;
+ else
+ of_root->child = overlay_base_root->child;
+
+ for_each_of_allnodes_from(overlay_base_root, np)
+ __of_attach_node_sysfs(np);
+
+ if (of_symbols) {
+ for_each_property_of_node(overlay_base_symbols, prop) {
+ ret = __of_add_property(of_symbols, prop);
+ if (ret) {
+ unittest(0,
+ "duplicate property '%s' in overlay_base node __symbols__",
+ prop->name);
+ return;
+ }
+ ret = __of_add_property_sysfs(of_symbols, prop);
+ if (ret) {
+ unittest(0,
+ "unable to add property '%s' in overlay_base node __symbols__ to sysfs",
+ prop->name);
+ return;
+ }
+ }
+ }
+
+ mutex_unlock(&of_mutex);
+
+
+ /* now do the normal overlay usage test */
+
+ unittest(overlay_data_add(1),
+ "Adding overlay 'overlay' failed\n");
+
+ unittest(overlay_data_add(2),
+ "Adding overlay 'overlay_bad_phandle' failed\n");
+}
+
+#else
+
+static inline __init void of_unittest_overlay_high_level(void) {}
+
+#endif
+
static int __init of_unittest(void)
{
struct device_node *np;
@@ -1962,6 +2277,8 @@ static int __init of_unittest(void)
/* Double check linkage after removing testcase data */
of_unittest_check_tree_linkage();
+ of_unittest_overlay_high_level();
+
pr_info("end of unittest - %i passed, %i failed\n",
unittest_results.passed, unittest_results.failed);
--
Frank Rowand <frank.rowand@sony.com>
^ permalink raw reply related
* Re: [PATCH v2 1/2] of: support dtc compiler flags for overlays
From: Frank Rowand @ 2017-04-26 0:10 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Rob Herring, Stephen Boyd, Michal Marek, devicetree,
Linux Kernel Mailing List, Linux Kbuild mailing list
In-Reply-To: <CAK7LNARd-XsCfSJhDj3JisH=u4XZm8DaPEa5Pg2ciWrq8Ueing@mail.gmail.com>
On 04/25/17 15:04, Masahiro Yamada wrote:
> 2017-04-25 8:05 GMT+09:00 <frowand.list@gmail.com>:
>> From: Frank Rowand <frank.rowand@sony.com>
>>
>> The dtc compiler version that adds initial support was available
>> in 4.11-rc1. Add the ability to set the dtc compiler flags needed
>> by overlays.
>>
>> Signed-off-by: Frank Rowand <frank.rowand@sony.com>
>> ---
>
>
> I know your motivation for 1/2 is overlay,
> but this patch itself is more generic.
> (support for per-file dtc compiler flag)
>
> Could you reword the commit subject a little bit?
>
> Otherwise,
>
> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Fixed in version 4.
-Frank
>
>
>
>> scripts/Makefile.lib | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
>> index 0a07f9014944..0bbec480d323 100644
>> --- a/scripts/Makefile.lib
>> +++ b/scripts/Makefile.lib
>> @@ -283,6 +283,8 @@ ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
>> DTC_FLAGS += -Wno-unit_address_vs_reg
>> endif
>>
>> +DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
>> +
>> # Generate an assembly file to wrap the output of the device tree compiler
>> quiet_cmd_dt_S_dtb= DTB $@
>> cmd_dt_S_dtb= \
>> --
>
>
^ permalink raw reply
* Re: [PATCH v2 2/2] ARM: dts: Add the ethernet and ethernet PHY to the cygnus core DT.
From: Andrew Lunn @ 2017-04-26 0:49 UTC (permalink / raw)
To: Eric Anholt
Cc: Florian Fainelli, Vivien Didelot, netdev, Rob Herring,
Mark Rutland, devicetree, linux-arm-kernel, linux-kernel,
bcm-kernel-feedback-list, Ray Jui, Scott Branden, Jon Mason
In-Reply-To: <20170425235357.7690-2-eric@anholt.net>
> + eth0: ethernet@18042000 {
> + compatible = "brcm,amac";
> + reg = <0x18042000 0x1000>,
> + <0x18110000 0x1000>;
> + reg-names = "amac_base", "idm_base";
> + interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
> + max-speed = <1000>;
Hi Eric
Sorry i missed this the first time. Does this Ethernet controller do >
1Gbps? Does this max-speed do anything useful?
Andrew
^ permalink raw reply
* RE: [PATCH v6 4/5] i2c: aspeed: added driver for Aspeed I2C
From: Ryan Chen @ 2017-04-26 0:52 UTC (permalink / raw)
To: Brendan Higgins
Cc: Benjamin Herrenschmidt, Wolfram Sang, Rob Herring, Mark Rutland,
Thomas Gleixner, Jason Cooper, Marc Zyngier, Joel Stanley,
Vladimir Zapolskiy, Kachalov Anton, Cédric Le Goater,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Linux Kernel Mailing List, OpenBMC Maillist
In-Reply-To: <CAFd5g45htFgr5oHbB9W_nyyMfm5J7BCKUuP73RxKhNW3LkWtyw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> Thanks Ryan. Can you shed some light on the meaning of the high-speed bit as well please ?
>
> About ASPEED_I2CD_M_HIGH_SPEED_EN, it is support for I2C specification "High speed transfer". And also device need support it.
> If you just speed up the I2C bus clock, you don’t have to enable ASPEED_I2CD_M_HIGH_SPEED_EN, just change the clock is ok.
>
>Interesting, I thought that ASPEED_I2CD_M_SDA_DRIVE_1T_EN and its counterpart would be used for fast mode or fast mode plus and ASPEED_I2CD_M_HIGH_SPEED_EN would be used for fast mode plus or high speed mode and that they work by driving the SDA and SCL signals to >improve rise times. It made sense to me because the lowest SCL you can get with base clock set to zero is about ~1.5MHz which is in between fast mode plus (1MHz) and high speed mode (3.4MHz).
>But from what you are saying, ASPEED_I2CD_M_SDA_DRIVE_1T_EN and its counterpart are totally orthogonal to the selected speed and ASPEED_I2CD_M_HIGH_SPEED_EN exists as a matter of convenience to set all of the divider registers to their smallest possible values. Is my >
>understanding correct?
In I2c specification[http://www.csd.uoc.gr/~hy428/reading/i2c_spec.pdf] there have a chapter about high speed transfer. It will start from specific command (00001XXX) and after that can transfer to high speed mode.
The following is our high speed mode programming guide. That also have description at AST2400 datasheet. 40.7.12
>
> -----Original Message-----
> From: Benjamin Herrenschmidt [mailto:benh@kernel.crashing.org]
> Sent: Tuesday, April 25, 2017 5:35 PM
> To: Ryan Chen <ryan_chen@aspeedtech.com>; Brendan Higgins
> <brendanhiggins@google.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>; Rob Herring
> <robh+dt@kernel.org>; Mark Rutland <mark.rutland@arm.com>; Thomas
> Gleixner <tglx@linutronix.de>; Jason Cooper <jason@lakedaemon.net>;
> Marc Zyngier <marc.zyngier@arm.com>; Joel Stanley <joel@jms.id.au>;
> Vladimir Zapolskiy <vz@mleia.com>; Kachalov Anton <mouse@mayc.ru>;
> Cédric Le Goater <clg@kaod.org>; linux-i2c@vger.kernel.org;
> devicetree@vger.kernel.org; Linux Kernel Mailing List
> <linux-kernel@vger.kernel.org>; OpenBMC Maillist
> <openbmc@lists.ozlabs.org>
> Subject: Re: [PATCH v6 4/5] i2c: aspeed: added driver for Aspeed I2C
>
> On Tue, 2017-04-25 at 08:50 +0000, Ryan Chen wrote:
>> Hello All,
>> ASPEED_I2CD_M_SDA_DRIVE_1T_EN,
>> ASPEED_I2CD_SDA_DRIVE_1T_EN is specific for some case usage.
>> For example, if i2c bus is use on "high speed" and
>> "single slave and master" and i2c bus is too long. It need drive SDA or SCL less lunacy.
>> It would enable it.
>> Otherwise, don’t enable it. especially in multi-master.
>> It can’t be enable.
>
> That smells like a specific enough use case that we should probably cover with a device-tree property, something like an empty "sda-extra-drive" property (empty properties are typically used for booleans, their presence means "true").
>
> Thanks Ryan. Can you shed some light on the meaning of the high-speed
> bit as well please ? Does it force to a specific speed (ignoring the
> divisor) or we can still play with the clock high/low counts ?
>
...
>> > Your latest patch still does that. It will do things like start a
>> > STOP command *then* ack the status bits. I'm pretty sure that's
>> > bogus.
>> >
>> > That way it's a lot simpler to simply move the
>> >
>> > writel(irq_status, bus->base + ASPEED_I2C_INTR_STS_REG);
>> >
>> > To either right after the readl of the status reg at the beginning
>> > of aspeed_i2c_master_irq().
>> >
>> > I would be very surprised if that didn't work properly and wasn't
>> > much safer than what you are currently doing.
>>
>> I think I tried your way and it worked. In anycase, Ryan will be able
>> to clarify for us.
After thinking about this more, I think Ben is right. It would be unusual for such a common convention to be broken and even if it is, I do not see how a command could take effect until it is actually issued. Nevertheless, it would make me feel better if you, Ryan, could comment on this.
>>
>> >
>> > > Let me know if you still think we need a "RECOVERY" state.
>> >
...
I feel pretty good about this; it does not look like there will be a lot of changes going into v8; hopefully, that version will be good enough to get merged.
^ permalink raw reply
* Re: Applied "ASoC: Add support for Maxim Integrated MAX98927 Amplifier" to the asoc tree
From: Ryan Lee @ 2017-04-26 2:51 UTC (permalink / raw)
To: Mark Brown
Cc: Liam Girdwood, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
mark.rutland-5wv7dgnIgG8, perex-/Fr2/VpizcU, tiwai-IBi9RG/b67k,
Kuninori Morimoto, Arnd Bergmann,
ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
lars-Qo5EllUWu/uELgA04lAiVw, bardliao-Rasf1IRRPZFBDgjK7y7TUQ,
nh6z-fFIq/eER6g8, KCHSU0-KrzQf0k3Iz9BDgjK7y7TUQ, Axel Lin,
romain.perier-ZGY8ohtN/8qB+jHODAdFcQ, Srinivas Kandagatla,
oder_chiou-Rasf1IRRPZFBDgjK7y7TUQ,
Paul.Handrigan-jGc1dHjMKG3QT0dZR+AlfA,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Dylan Reid, Ryan Lee
In-Reply-To: <CAN4-oj=+WuNShte3e27XCWNHVTw6dBTUiQ=dmCLcX6nA9zx1eg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Tue, Apr 25, 2017 at 9:51 AM, Ryan Lee <ryans.lee-zxKO94PEStzToO697jQleEEOCMrvLtNR@public.gmane.org> wrote:
> '
>
> On Thu, Apr 6, 2017 at 11:55 AM, Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
>> The patch
>>
>> ASoC: Add support for Maxim Integrated MAX98927 Amplifier
>>
>> has been applied to the asoc tree at
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
>>
>> All being well this means that it will be integrated into the linux-next
>> tree (usually sometime in the next 24 hours) and sent to Linus during
>> the next merge window (or sooner if it is a bug fix), however if
>> problems are discovered then the patch may be dropped or reverted.
>>
>> You may get further e-mails resulting from automated or manual testing
>> and review of the tree, please engage with people reporting problems and
>> send followup patches addressing any issues that are reported if needed.
>>
>> If any updates are required or you are submitting further changes they
>> should be sent as incremental updates against current git, existing
>> patches will not be replaced.
>>
>> Please add any relevant lists and maintainers to the CCs when replying
>> to this mail.
>>
>> Thanks,
>> Mark
>
> I have tried to check MAX98927 driver on linux-next tree and
> 'git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git' but
> have failed.
> So I wanted to check the current status of MAX98927 driver.
> I'm sorry for top-posting.
Please ignore this mail.
I just checked it is on linux-next tree.
I'm sorry again to make people confused.
>
>>
>> From 7c0c2000716e64151b3c0c62026c18f31537ebe9 Mon Sep 17 00:00:00 2001
>> From: Ryan Lee <ryans.lee-zxKO94PEStzToO697jQleEEOCMrvLtNR@public.gmane.org>
>> Date: Tue, 4 Apr 2017 02:23:08 +0900
>> Subject: [PATCH] ASoC: Add support for Maxim Integrated MAX98927 Amplifier
>>
>> Signed-off-by: Ryan Lee <ryans.lee-zxKO94PEStzToO697jQleEEOCMrvLtNR@public.gmane.org>
>> Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>> ---
>> .../devicetree/bindings/sound/max98925.txt | 22 -
>> .../devicetree/bindings/sound/max98926.txt | 32 -
>> .../devicetree/bindings/sound/max9892x.txt | 41 +
>> sound/soc/codecs/Kconfig | 5 +
>> sound/soc/codecs/Makefile | 2 +
>> sound/soc/codecs/max98927.c | 841 +++++++++++++++++++++
>> sound/soc/codecs/max98927.h | 272 +++++++
>> 7 files changed, 1161 insertions(+), 54 deletions(-)
>> delete mode 100644 Documentation/devicetree/bindings/sound/max98925.txt
>> delete mode 100644 Documentation/devicetree/bindings/sound/max98926.txt
>> create mode 100644 Documentation/devicetree/bindings/sound/max9892x.txt
>> create mode 100644 sound/soc/codecs/max98927.c
>> create mode 100644 sound/soc/codecs/max98927.h
>>
>> diff --git a/Documentation/devicetree/bindings/sound/max98925.txt b/Documentation/devicetree/bindings/sound/max98925.txt
>> deleted file mode 100644
>> index 27be63e2aa0d..000000000000
>> --- a/Documentation/devicetree/bindings/sound/max98925.txt
>> +++ /dev/null
>> @@ -1,22 +0,0 @@
>> -max98925 audio CODEC
>> -
>> -This device supports I2C.
>> -
>> -Required properties:
>> -
>> - - compatible : "maxim,max98925"
>> -
>> - - vmon-slot-no : slot number used to send voltage information
>> -
>> - - imon-slot-no : slot number used to send current information
>> -
>> - - reg : the I2C address of the device for I2C
>> -
>> -Example:
>> -
>> -codec: max98925@1a {
>> - compatible = "maxim,max98925";
>> - vmon-slot-no = <0>;
>> - imon-slot-no = <2>;
>> - reg = <0x1a>;
>> -};
>> diff --git a/Documentation/devicetree/bindings/sound/max98926.txt b/Documentation/devicetree/bindings/sound/max98926.txt
>> deleted file mode 100644
>> index 0b7f4e4d5f9a..000000000000
>> --- a/Documentation/devicetree/bindings/sound/max98926.txt
>> +++ /dev/null
>> @@ -1,32 +0,0 @@
>> -max98926 audio CODEC
>> -
>> -This device supports I2C.
>> -
>> -Required properties:
>> -
>> - - compatible : "maxim,max98926"
>> -
>> - - vmon-slot-no : slot number used to send voltage information
>> - or in inteleave mode this will be used as
>> - interleave slot.
>> -
>> - - imon-slot-no : slot number used to send current information
>> -
>> - - interleave-mode : When using two MAX98926 in a system it is
>> - possible to create ADC data that that will
>> - overflow the frame size. Digital Audio Interleave
>> - mode provides a means to output VMON and IMON data
>> - from two devices on a single DOUT line when running
>> - smaller frames sizes such as 32 BCLKS per LRCLK or
>> - 48 BCLKS per LRCLK.
>> -
>> - - reg : the I2C address of the device for I2C
>> -
>> -Example:
>> -
>> -codec: max98926@1a {
>> - compatible = "maxim,max98926";
>> - vmon-slot-no = <0>;
>> - imon-slot-no = <2>;
>> - reg = <0x1a>;
>> -};
>> diff --git a/Documentation/devicetree/bindings/sound/max9892x.txt b/Documentation/devicetree/bindings/sound/max9892x.txt
>> new file mode 100644
>> index 000000000000..f6171591ddc6
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/sound/max9892x.txt
>> @@ -0,0 +1,41 @@
>> +Maxim Integrated MAX98925/MAX98926/MAX98927 Speaker Amplifier
>> +
>> +This device supports I2C.
>> +
>> +Required properties:
>> +
>> + - compatible : should be one of the following
>> + - "maxim,max98925"
>> + - "maxim,max98926"
>> + - "maxim,max98927"
>> +
>> + - vmon-slot-no : slot number used to send voltage information
>> + or in inteleave mode this will be used as
>> + interleave slot.
>> + MAX98925/MAX98926 slot range : 0 ~ 30, Default : 0
>> + MAX98927 slot range : 0 ~ 15, Default : 0
>> +
>> + - imon-slot-no : slot number used to send current information
>> + MAX98925/MAX98926 slot range : 0 ~ 30, Default : 0
>> + MAX98927 slot range : 0 ~ 15, Default : 0
>> +
>> + - interleave-mode : When using two MAX9892X in a system it is
>> + possible to create ADC data that that will
>> + overflow the frame size. Digital Audio Interleave
>> + mode provides a means to output VMON and IMON data
>> + from two devices on a single DOUT line when running
>> + smaller frames sizes such as 32 BCLKS per LRCLK or
>> + 48 BCLKS per LRCLK.
>> + Range : 0 (off), 1 (on), Default : 0
>> +
>> + - reg : the I2C address of the device for I2C
>> +
>> +Example:
>> +
>> +codec: max98927@3a {
>> + compatible = "maxim,max98927";
>> + vmon-slot-no = <0>;
>> + imon-slot-no = <1>;
>> + interleave-mode = <0>;
>> + reg = <0x3a>;
>> +};
>> diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
>> index 9e1718a8cb1c..65e31ab88280 100644
>> --- a/sound/soc/codecs/Kconfig
>> +++ b/sound/soc/codecs/Kconfig
>> @@ -89,6 +89,7 @@ config SND_SOC_ALL_CODECS
>> select SND_SOC_MAX9867 if I2C
>> select SND_SOC_MAX98925 if I2C
>> select SND_SOC_MAX98926 if I2C
>> + select SND_SOC_MAX98927 if I2C
>> select SND_SOC_MAX9850 if I2C
>> select SND_SOC_MAX9860 if I2C
>> select SND_SOC_MAX9768 if I2C
>> @@ -585,6 +586,10 @@ config SND_SOC_MAX98925
>> config SND_SOC_MAX98926
>> tristate
>>
>> +config SND_SOC_MAX98927
>> + tristate "Maxim Integrated MAX98927 Speaker Amplifier"
>> + depends on I2C
>> +
>> config SND_SOC_MAX9850
>> tristate
>>
>> diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
>> index 7e1dad79610b..64656c43200c 100644
>> --- a/sound/soc/codecs/Makefile
>> +++ b/sound/soc/codecs/Makefile
>> @@ -84,6 +84,7 @@ snd-soc-max98371-objs := max98371.o
>> snd-soc-max9867-objs := max9867.o
>> snd-soc-max98925-objs := max98925.o
>> snd-soc-max98926-objs := max98926.o
>> +snd-soc-max98927-objs := max98927.o
>> snd-soc-max9850-objs := max9850.o
>> snd-soc-max9860-objs := max9860.o
>> snd-soc-mc13783-objs := mc13783.o
>> @@ -312,6 +313,7 @@ obj-$(CONFIG_SND_SOC_MAX98357A) += snd-soc-max98357a.o
>> obj-$(CONFIG_SND_SOC_MAX9867) += snd-soc-max9867.o
>> obj-$(CONFIG_SND_SOC_MAX98925) += snd-soc-max98925.o
>> obj-$(CONFIG_SND_SOC_MAX98926) += snd-soc-max98926.o
>> +obj-$(CONFIG_SND_SOC_MAX98927) += snd-soc-max98927.o
>> obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o
>> obj-$(CONFIG_SND_SOC_MAX9860) += snd-soc-max9860.o
>> obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o
>> diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c
>> new file mode 100644
>> index 000000000000..b5ee29499e16
>> --- /dev/null
>> +++ b/sound/soc/codecs/max98927.c
>> @@ -0,0 +1,841 @@
>> +/*
>> + * max98927.c -- MAX98927 ALSA Soc Audio driver
>> + *
>> + * Copyright (C) 2016 Maxim Integrated Products
>> + * Author: Ryan Lee <ryans.lee-zxKO94PEStzToO697jQleEEOCMrvLtNR@public.gmane.org>
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU General Public License as published by the
>> + * Free Software Foundation; either version 2 of the License, or (at your
>> + * option) any later version.
>> + */
>> +
>> +#include <linux/acpi.h>
>> +#include <linux/i2c.h>
>> +#include <linux/module.h>
>> +#include <linux/regmap.h>
>> +#include <linux/slab.h>
>> +#include <linux/cdev.h>
>> +#include <sound/pcm.h>
>> +#include <sound/pcm_params.h>
>> +#include <sound/soc.h>
>> +#include <linux/gpio.h>
>> +#include <linux/of_gpio.h>
>> +#include <sound/tlv.h>
>> +#include "max98927.h"
>> +
>> +static struct reg_default max98927_reg[] = {
>> + {MAX98927_R0001_INT_RAW1, 0x00},
>> + {MAX98927_R0002_INT_RAW2, 0x00},
>> + {MAX98927_R0003_INT_RAW3, 0x00},
>> + {MAX98927_R0004_INT_STATE1, 0x00},
>> + {MAX98927_R0005_INT_STATE2, 0x00},
>> + {MAX98927_R0006_INT_STATE3, 0x00},
>> + {MAX98927_R0007_INT_FLAG1, 0x00},
>> + {MAX98927_R0008_INT_FLAG2, 0x00},
>> + {MAX98927_R0009_INT_FLAG3, 0x00},
>> + {MAX98927_R000A_INT_EN1, 0x00},
>> + {MAX98927_R000B_INT_EN2, 0x00},
>> + {MAX98927_R000C_INT_EN3, 0x00},
>> + {MAX98927_R000D_INT_FLAG_CLR1, 0x00},
>> + {MAX98927_R000E_INT_FLAG_CLR2, 0x00},
>> + {MAX98927_R000F_INT_FLAG_CLR3, 0x00},
>> + {MAX98927_R0010_IRQ_CTRL, 0x00},
>> + {MAX98927_R0011_CLK_MON, 0x00},
>> + {MAX98927_R0012_WDOG_CTRL, 0x00},
>> + {MAX98927_R0013_WDOG_RST, 0x00},
>> + {MAX98927_R0014_MEAS_ADC_THERM_WARN_THRESH, 0x00},
>> + {MAX98927_R0015_MEAS_ADC_THERM_SHDN_THRESH, 0x00},
>> + {MAX98927_R0016_MEAS_ADC_THERM_HYSTERESIS, 0x00},
>> + {MAX98927_R0017_PIN_CFG, 0x55},
>> + {MAX98927_R0018_PCM_RX_EN_A, 0x00},
>> + {MAX98927_R0019_PCM_RX_EN_B, 0x00},
>> + {MAX98927_R001A_PCM_TX_EN_A, 0x00},
>> + {MAX98927_R001B_PCM_TX_EN_B, 0x00},
>> + {MAX98927_R001C_PCM_TX_HIZ_CTRL_A, 0x00},
>> + {MAX98927_R001D_PCM_TX_HIZ_CTRL_B, 0x00},
>> + {MAX98927_R001E_PCM_TX_CH_SRC_A, 0x00},
>> + {MAX98927_R001F_PCM_TX_CH_SRC_B, 0x00},
>> + {MAX98927_R0020_PCM_MODE_CFG, 0x40},
>> + {MAX98927_R0021_PCM_MASTER_MODE, 0x00},
>> + {MAX98927_R0022_PCM_CLK_SETUP, 0x22},
>> + {MAX98927_R0023_PCM_SR_SETUP1, 0x00},
>> + {MAX98927_R0024_PCM_SR_SETUP2, 0x00},
>> + {MAX98927_R0025_PCM_TO_SPK_MONOMIX_A, 0x00},
>> + {MAX98927_R0026_PCM_TO_SPK_MONOMIX_B, 0x00},
>> + {MAX98927_R0027_ICC_RX_EN_A, 0x00},
>> + {MAX98927_R0028_ICC_RX_EN_B, 0x00},
>> + {MAX98927_R002B_ICC_TX_EN_A, 0x00},
>> + {MAX98927_R002C_ICC_TX_EN_B, 0x00},
>> + {MAX98927_R002E_ICC_HIZ_MANUAL_MODE, 0x00},
>> + {MAX98927_R002F_ICC_TX_HIZ_EN_A, 0x00},
>> + {MAX98927_R0030_ICC_TX_HIZ_EN_B, 0x00},
>> + {MAX98927_R0031_ICC_LNK_EN, 0x00},
>> + {MAX98927_R0032_PDM_TX_EN, 0x00},
>> + {MAX98927_R0033_PDM_TX_HIZ_CTRL, 0x00},
>> + {MAX98927_R0034_PDM_TX_CTRL, 0x00},
>> + {MAX98927_R0035_PDM_RX_CTRL, 0x00},
>> + {MAX98927_R0036_AMP_VOL_CTRL, 0x00},
>> + {MAX98927_R0037_AMP_DSP_CFG, 0x02},
>> + {MAX98927_R0038_TONE_GEN_DC_CFG, 0x00},
>> + {MAX98927_R0039_DRE_CTRL, 0x01},
>> + {MAX98927_R003A_AMP_EN, 0x00},
>> + {MAX98927_R003B_SPK_SRC_SEL, 0x00},
>> + {MAX98927_R003C_SPK_GAIN, 0x00},
>> + {MAX98927_R003D_SSM_CFG, 0x01},
>> + {MAX98927_R003E_MEAS_EN, 0x00},
>> + {MAX98927_R003F_MEAS_DSP_CFG, 0x04},
>> + {MAX98927_R0040_BOOST_CTRL0, 0x00},
>> + {MAX98927_R0041_BOOST_CTRL3, 0x00},
>> + {MAX98927_R0042_BOOST_CTRL1, 0x00},
>> + {MAX98927_R0043_MEAS_ADC_CFG, 0x00},
>> + {MAX98927_R0044_MEAS_ADC_BASE_MSB, 0x00},
>> + {MAX98927_R0045_MEAS_ADC_BASE_LSB, 0x00},
>> + {MAX98927_R0046_ADC_CH0_DIVIDE, 0x00},
>> + {MAX98927_R0047_ADC_CH1_DIVIDE, 0x00},
>> + {MAX98927_R0048_ADC_CH2_DIVIDE, 0x00},
>> + {MAX98927_R0049_ADC_CH0_FILT_CFG, 0x00},
>> + {MAX98927_R004A_ADC_CH1_FILT_CFG, 0x00},
>> + {MAX98927_R004B_ADC_CH2_FILT_CFG, 0x00},
>> + {MAX98927_R004C_MEAS_ADC_CH0_READ, 0x00},
>> + {MAX98927_R004D_MEAS_ADC_CH1_READ, 0x00},
>> + {MAX98927_R004E_MEAS_ADC_CH2_READ, 0x00},
>> + {MAX98927_R0051_BROWNOUT_STATUS, 0x00},
>> + {MAX98927_R0052_BROWNOUT_EN, 0x00},
>> + {MAX98927_R0053_BROWNOUT_INFINITE_HOLD, 0x00},
>> + {MAX98927_R0054_BROWNOUT_INFINITE_HOLD_CLR, 0x00},
>> + {MAX98927_R0055_BROWNOUT_LVL_HOLD, 0x00},
>> + {MAX98927_R005A_BROWNOUT_LVL1_THRESH, 0x00},
>> + {MAX98927_R005B_BROWNOUT_LVL2_THRESH, 0x00},
>> + {MAX98927_R005C_BROWNOUT_LVL3_THRESH, 0x00},
>> + {MAX98927_R005D_BROWNOUT_LVL4_THRESH, 0x00},
>> + {MAX98927_R005E_BROWNOUT_THRESH_HYSTERYSIS, 0x00},
>> + {MAX98927_R005F_BROWNOUT_AMP_LIMITER_ATK_REL, 0x00},
>> + {MAX98927_R0060_BROWNOUT_AMP_GAIN_ATK_REL, 0x00},
>> + {MAX98927_R0061_BROWNOUT_AMP1_CLIP_MODE, 0x00},
>> + {MAX98927_R0072_BROWNOUT_LVL1_CUR_LIMIT, 0x00},
>> + {MAX98927_R0073_BROWNOUT_LVL1_AMP1_CTRL1, 0x00},
>> + {MAX98927_R0074_BROWNOUT_LVL1_AMP1_CTRL2, 0x00},
>> + {MAX98927_R0075_BROWNOUT_LVL1_AMP1_CTRL3, 0x00},
>> + {MAX98927_R0076_BROWNOUT_LVL2_CUR_LIMIT, 0x00},
>> + {MAX98927_R0077_BROWNOUT_LVL2_AMP1_CTRL1, 0x00},
>> + {MAX98927_R0078_BROWNOUT_LVL2_AMP1_CTRL2, 0x00},
>> + {MAX98927_R0079_BROWNOUT_LVL2_AMP1_CTRL3, 0x00},
>> + {MAX98927_R007A_BROWNOUT_LVL3_CUR_LIMIT, 0x00},
>> + {MAX98927_R007B_BROWNOUT_LVL3_AMP1_CTRL1, 0x00},
>> + {MAX98927_R007C_BROWNOUT_LVL3_AMP1_CTRL2, 0x00},
>> + {MAX98927_R007D_BROWNOUT_LVL3_AMP1_CTRL3, 0x00},
>> + {MAX98927_R007E_BROWNOUT_LVL4_CUR_LIMIT, 0x00},
>> + {MAX98927_R007F_BROWNOUT_LVL4_AMP1_CTRL1, 0x00},
>> + {MAX98927_R0080_BROWNOUT_LVL4_AMP1_CTRL2, 0x00},
>> + {MAX98927_R0081_BROWNOUT_LVL4_AMP1_CTRL3, 0x00},
>> + {MAX98927_R0082_ENV_TRACK_VOUT_HEADROOM, 0x00},
>> + {MAX98927_R0083_ENV_TRACK_BOOST_VOUT_DELAY, 0x00},
>> + {MAX98927_R0084_ENV_TRACK_REL_RATE, 0x00},
>> + {MAX98927_R0085_ENV_TRACK_HOLD_RATE, 0x00},
>> + {MAX98927_R0086_ENV_TRACK_CTRL, 0x00},
>> + {MAX98927_R0087_ENV_TRACK_BOOST_VOUT_READ, 0x00},
>> + {MAX98927_R00FF_GLOBAL_SHDN, 0x00},
>> + {MAX98927_R0100_SOFT_RESET, 0x00},
>> + {MAX98927_R01FF_REV_ID, 0x40},
>> +};
>> +
>> +static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
>> +{
>> + struct snd_soc_codec *codec = codec_dai->codec;
>> + struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec);
>> + unsigned int mode = 0;
>> + unsigned int format = 0;
>> + unsigned int invert = 0;
>> +
>> + dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt);
>> +
>> + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
>> + case SND_SOC_DAIFMT_CBS_CFS:
>> + mode = MAX98927_PCM_MASTER_MODE_SLAVE;
>> + break;
>> + case SND_SOC_DAIFMT_CBM_CFM:
>> + max98927->master = true;
>> + mode = MAX98927_PCM_MASTER_MODE_MASTER;
>> + break;
>> + default:
>> + dev_err(codec->dev, "DAI clock mode unsupported");
>> + return -EINVAL;
>> + }
>> +
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0021_PCM_MASTER_MODE,
>> + MAX98927_PCM_MASTER_MODE_MASK,
>> + mode);
>> +
>> + switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
>> + case SND_SOC_DAIFMT_NB_NF:
>> + break;
>> + case SND_SOC_DAIFMT_IB_NF:
>> + invert = MAX98927_PCM_MODE_CFG_PCM_BCLKEDGE;
>> + break;
>> + default:
>> + dev_err(codec->dev, "DAI invert mode unsupported");
>> + return -EINVAL;
>> + }
>> +
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0020_PCM_MODE_CFG,
>> + MAX98927_PCM_MODE_CFG_PCM_BCLKEDGE,
>> + invert);
>> +
>> + /* interface format */
>> + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
>> + case SND_SOC_DAIFMT_I2S:
>> + max98927->iface |= SND_SOC_DAIFMT_I2S;
>> + format = MAX98927_PCM_FORMAT_I2S;
>> + break;
>> + case SND_SOC_DAIFMT_LEFT_J:
>> + max98927->iface |= SND_SOC_DAIFMT_LEFT_J;
>> + format = MAX98927_PCM_FORMAT_LJ;
>> + break;
>> + case SND_SOC_DAIFMT_PDM:
>> + max98927->iface |= SND_SOC_DAIFMT_PDM;
>> + break;
>> + default:
>> + return -EINVAL;
>> + }
>> +
>> + /* pcm channel configuration */
>> + if (max98927->iface & (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_LEFT_J)) {
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0018_PCM_RX_EN_A,
>> + MAX98927_PCM_RX_CH0_EN | MAX98927_PCM_RX_CH1_EN,
>> + MAX98927_PCM_RX_CH0_EN | MAX98927_PCM_RX_CH1_EN);
>> +
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0020_PCM_MODE_CFG,
>> + MAX98927_PCM_MODE_CFG_FORMAT_MASK,
>> + format << MAX98927_PCM_MODE_CFG_FORMAT_SHIFT);
>> +
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R003B_SPK_SRC_SEL,
>> + MAX98927_SPK_SRC_MASK, 0);
>> +
>> + } else
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0018_PCM_RX_EN_A,
>> + MAX98927_PCM_RX_CH0_EN | MAX98927_PCM_RX_CH1_EN, 0);
>> +
>> + /* pdm channel configuration */
>> + if (max98927->iface & SND_SOC_DAIFMT_PDM) {
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0035_PDM_RX_CTRL,
>> + MAX98927_PDM_RX_EN_MASK, 1);
>> +
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R003B_SPK_SRC_SEL,
>> + MAX98927_SPK_SRC_MASK, 3);
>> + } else
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0035_PDM_RX_CTRL,
>> + MAX98927_PDM_RX_EN_MASK, 0);
>> + return 0;
>> +}
>> +
>> +/* codec MCLK rate in master mode */
>> +static const int rate_table[] = {
>> + 5644800, 6000000, 6144000, 6500000,
>> + 9600000, 11289600, 12000000, 12288000,
>> + 13000000, 19200000,
>> +};
>> +
>> +static int max98927_set_clock(struct max98927_priv *max98927,
>> + struct snd_pcm_hw_params *params)
>> +{
>> + struct snd_soc_codec *codec = max98927->codec;
>> + /* BCLK/LRCLK ratio calculation */
>> + int blr_clk_ratio = params_channels(params) * max98927->ch_size;
>> + int value;
>> +
>> + if (max98927->master) {
>> + int i;
>> + /* match rate to closest value */
>> + for (i = 0; i < ARRAY_SIZE(rate_table); i++) {
>> + if (rate_table[i] >= max98927->sysclk)
>> + break;
>> + }
>> + if (i == ARRAY_SIZE(rate_table)) {
>> + dev_err(codec->dev, "failed to find proper clock rate.\n");
>> + return -EINVAL;
>> + }
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0021_PCM_MASTER_MODE,
>> + MAX98927_PCM_MASTER_MODE_MCLK_MASK,
>> + i << MAX98927_PCM_MASTER_MODE_MCLK_RATE_SHIFT);
>> + }
>> +
>> + switch (blr_clk_ratio) {
>> + case 32:
>> + value = 2;
>> + break;
>> + case 48:
>> + value = 3;
>> + break;
>> + case 64:
>> + value = 4;
>> + break;
>> + default:
>> + return -EINVAL;
>> + }
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0022_PCM_CLK_SETUP,
>> + MAX98927_PCM_CLK_SETUP_BSEL_MASK,
>> + value);
>> + return 0;
>> +}
>> +
>> +static int max98927_dai_hw_params(struct snd_pcm_substream *substream,
>> + struct snd_pcm_hw_params *params,
>> + struct snd_soc_dai *dai)
>> +{
>> + struct snd_soc_codec *codec = dai->codec;
>> + struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec);
>> + unsigned int sampling_rate = 0;
>> + unsigned int chan_sz = 0;
>> +
>> + /* pcm mode configuration */
>> + switch (snd_pcm_format_width(params_format(params))) {
>> + case 16:
>> + chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_16;
>> + break;
>> + case 24:
>> + chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_24;
>> + break;
>> + case 32:
>> + chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32;
>> + break;
>> + default:
>> + dev_err(codec->dev, "format unsupported %d",
>> + params_format(params));
>> + goto err;
>> + }
>> +
>> + max98927->ch_size = snd_pcm_format_width(params_format(params));
>> +
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0020_PCM_MODE_CFG,
>> + MAX98927_PCM_MODE_CFG_CHANSZ_MASK, chan_sz);
>> +
>> + dev_dbg(codec->dev, "format supported %d",
>> + params_format(params));
>> +
>> + /* sampling rate configuration */
>> + switch (params_rate(params)) {
>> + case 8000:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_8000;
>> + break;
>> + case 11025:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_11025;
>> + break;
>> + case 12000:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_12000;
>> + break;
>> + case 16000:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_16000;
>> + break;
>> + case 22050:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_22050;
>> + break;
>> + case 24000:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_24000;
>> + break;
>> + case 32000:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_32000;
>> + break;
>> + case 44100:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_44100;
>> + break;
>> + case 48000:
>> + sampling_rate = MAX98927_PCM_SR_SET1_SR_48000;
>> + break;
>> + default:
>> + dev_err(codec->dev, "rate %d not supported\n",
>> + params_rate(params));
>> + goto err;
>> + }
>> + /* set DAI_SR to correct LRCLK frequency */
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0023_PCM_SR_SETUP1,
>> + MAX98927_PCM_SR_SET1_SR_MASK,
>> + sampling_rate);
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0024_PCM_SR_SETUP2,
>> + MAX98927_PCM_SR_SET2_SR_MASK,
>> + sampling_rate << MAX98927_PCM_SR_SET2_SR_SHIFT);
>> +
>> + /* set sampling rate of IV */
>> + if (max98927->interleave_mode &&
>> + sampling_rate > MAX98927_PCM_SR_SET1_SR_16000)
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0024_PCM_SR_SETUP2,
>> + MAX98927_PCM_SR_SET2_IVADC_SR_MASK,
>> + sampling_rate - 3);
>> + else
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R0024_PCM_SR_SETUP2,
>> + MAX98927_PCM_SR_SET2_IVADC_SR_MASK,
>> + sampling_rate);
>> + return max98927_set_clock(max98927, params);
>> +err:
>> + return -EINVAL;
>> +}
>> +
>> +#define MAX98927_RATES SNDRV_PCM_RATE_8000_48000
>> +
>> +#define MAX98927_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
>> + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
>> +
>> +static int max98927_dai_set_sysclk(struct snd_soc_dai *dai,
>> + int clk_id, unsigned int freq, int dir)
>> +{
>> + struct snd_soc_codec *codec = dai->codec;
>> + struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec);
>> +
>> + max98927->sysclk = freq;
>> + return 0;
>> +}
>> +
>> +static const struct snd_soc_dai_ops max98927_dai_ops = {
>> + .set_sysclk = max98927_dai_set_sysclk,
>> + .set_fmt = max98927_dai_set_fmt,
>> + .hw_params = max98927_dai_hw_params,
>> +};
>> +
>> +static int max98927_dac_event(struct snd_soc_dapm_widget *w,
>> + struct snd_kcontrol *kcontrol, int event)
>> +{
>> + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
>> + struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec);
>> +
>> + switch (event) {
>> + case SND_SOC_DAPM_POST_PMU:
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R003A_AMP_EN,
>> + MAX98927_AMP_EN_MASK, 1);
>> + /* enable VMON and IMON */
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R003E_MEAS_EN,
>> + MAX98927_MEAS_V_EN | MAX98927_MEAS_I_EN,
>> + MAX98927_MEAS_V_EN | MAX98927_MEAS_I_EN);
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R00FF_GLOBAL_SHDN,
>> + MAX98927_GLOBAL_EN_MASK, 1);
>> + break;
>> + case SND_SOC_DAPM_POST_PMD:
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R00FF_GLOBAL_SHDN,
>> + MAX98927_GLOBAL_EN_MASK, 0);
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R003A_AMP_EN,
>> + MAX98927_AMP_EN_MASK, 0);
>> + /* disable VMON and IMON */
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R003E_MEAS_EN,
>> + MAX98927_MEAS_V_EN | MAX98927_MEAS_I_EN, 0);
>> + break;
>> + default:
>> + return 0;
>> + }
>> + return 0;
>> +}
>> +
>> +static const char * const max98927_switch_text[] = {
>> + "Left", "Right", "LeftRight"};
>> +
>> +static const struct soc_enum dai_sel_enum =
>> + SOC_ENUM_SINGLE(MAX98927_R0025_PCM_TO_SPK_MONOMIX_A,
>> + MAX98927_PCM_TO_SPK_MONOMIX_CFG_SHIFT,
>> + 3, max98927_switch_text);
>> +
>> +static const struct snd_kcontrol_new max98927_dai_controls =
>> + SOC_DAPM_ENUM("DAI Sel", dai_sel_enum);
>> +
>> +static const struct snd_soc_dapm_widget max98927_dapm_widgets[] = {
>> + SND_SOC_DAPM_AIF_IN("DAI_OUT", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
>> + SND_SOC_DAPM_DAC_E("Amp Enable", "HiFi Playback", MAX98927_R003A_AMP_EN,
>> + 0, 0, max98927_dac_event,
>> + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD),
>> + SND_SOC_DAPM_MUX("DAI Sel Mux", SND_SOC_NOPM, 0, 0,
>> + &max98927_dai_controls),
>> + SND_SOC_DAPM_OUTPUT("BE_OUT"),
>> +};
>> +
>> +static DECLARE_TLV_DB_SCALE(max98927_spk_tlv, 300, 300, 0);
>> +static DECLARE_TLV_DB_SCALE(max98927_digital_tlv, -1600, 25, 0);
>> +
>> +static bool max98927_readable_register(struct device *dev, unsigned int reg)
>> +{
>> + switch (reg) {
>> + case MAX98927_R0001_INT_RAW1 ... MAX98927_R0028_ICC_RX_EN_B:
>> + case MAX98927_R002B_ICC_TX_EN_A ... MAX98927_R002C_ICC_TX_EN_B:
>> + case MAX98927_R002E_ICC_HIZ_MANUAL_MODE
>> + ... MAX98927_R004E_MEAS_ADC_CH2_READ:
>> + case MAX98927_R0051_BROWNOUT_STATUS
>> + ... MAX98927_R0055_BROWNOUT_LVL_HOLD:
>> + case MAX98927_R005A_BROWNOUT_LVL1_THRESH
>> + ... MAX98927_R0061_BROWNOUT_AMP1_CLIP_MODE:
>> + case MAX98927_R0072_BROWNOUT_LVL1_CUR_LIMIT
>> + ... MAX98927_R0087_ENV_TRACK_BOOST_VOUT_READ:
>> + case MAX98927_R00FF_GLOBAL_SHDN:
>> + case MAX98927_R0100_SOFT_RESET:
>> + case MAX98927_R01FF_REV_ID:
>> + return true;
>> + default:
>> + return false;
>> + }
>> +};
>> +
>> +static bool max98927_volatile_reg(struct device *dev, unsigned int reg)
>> +{
>> + switch (reg) {
>> + case MAX98927_R0001_INT_RAW1 ... MAX98927_R0009_INT_FLAG3:
>> + return true;
>> + default:
>> + return false;
>> + }
>> +}
>> +
>> +static const char * const max98927_boost_voltage_text[] = {
>> + "6.5V", "6.625V", "6.75V", "6.875V", "7V", "7.125V", "7.25V", "7.375V",
>> + "7.5V", "7.625V", "7.75V", "7.875V", "8V", "8.125V", "8.25V", "8.375V",
>> + "8.5V", "8.625V", "8.75V", "8.875V", "9V", "9.125V", "9.25V", "9.375V",
>> + "9.5V", "9.625V", "9.75V", "9.875V", "10V"
>> +};
>> +
>> +static SOC_ENUM_SINGLE_DECL(max98927_boost_voltage,
>> + MAX98927_R0040_BOOST_CTRL0, 0,
>> + max98927_boost_voltage_text);
>> +
>> +static const char * const max98927_current_limit_text[] = {
>> + "1.00A", "1.10A", "1.20A", "1.30A", "1.40A", "1.50A", "1.60A", "1.70A",
>> + "1.80A", "1.90A", "2.00A", "2.10A", "2.20A", "2.30A", "2.40A", "2.50A",
>> + "2.60A", "2.70A", "2.80A", "2.90A", "3.00A", "3.10A", "3.20A", "3.30A",
>> + "3.40A", "3.50A", "3.60A", "3.70A", "3.80A", "3.90A", "4.00A", "4.10A"
>> +};
>> +
>> +static SOC_ENUM_SINGLE_DECL(max98927_current_limit,
>> + MAX98927_R0042_BOOST_CTRL1, 1,
>> + max98927_current_limit_text);
>> +
>> +static const struct snd_kcontrol_new max98927_snd_controls[] = {
>> + SOC_SINGLE_TLV("Speaker Volume", MAX98927_R003C_SPK_GAIN,
>> + 0, 6, 0,
>> + max98927_spk_tlv),
>> + SOC_SINGLE_TLV("Digital Volume", MAX98927_R0036_AMP_VOL_CTRL,
>> + 0, (1<<MAX98927_AMP_VOL_WIDTH)-1, 0,
>> + max98927_digital_tlv),
>> + SOC_SINGLE("Amp DSP Switch", MAX98927_R0052_BROWNOUT_EN,
>> + MAX98927_BROWNOUT_DSP_SHIFT, 1, 0),
>> + SOC_SINGLE("Ramp Switch", MAX98927_R0037_AMP_DSP_CFG,
>> + MAX98927_AMP_DSP_CFG_RMP_SHIFT, 1, 0),
>> + SOC_SINGLE("DRE Switch", MAX98927_R0039_DRE_CTRL,
>> + MAX98927_DRE_EN_SHIFT, 1, 0),
>> + SOC_SINGLE("Volume Location Switch", MAX98927_R0036_AMP_VOL_CTRL,
>> + MAX98927_AMP_VOL_SEL_SHIFT, 1, 0),
>> + SOC_ENUM("Boost Output Voltage", max98927_boost_voltage),
>> + SOC_ENUM("Current Limit", max98927_current_limit),
>> +};
>> +
>> +static const struct snd_soc_dapm_route max98927_audio_map[] = {
>> + {"Amp Enable", NULL, "DAI_OUT"},
>> + {"DAI Sel Mux", "Left", "Amp Enable"},
>> + {"DAI Sel Mux", "Right", "Amp Enable"},
>> + {"DAI Sel Mux", "LeftRight", "Amp Enable"},
>> + {"BE_OUT", NULL, "DAI Sel Mux"},
>> +};
>> +
>> +static struct snd_soc_dai_driver max98927_dai[] = {
>> + {
>> + .name = "max98927-aif1",
>> + .playback = {
>> + .stream_name = "HiFi Playback",
>> + .channels_min = 1,
>> + .channels_max = 2,
>> + .rates = MAX98927_RATES,
>> + .formats = MAX98927_FORMATS,
>> + },
>> + .capture = {
>> + .stream_name = "HiFi Capture",
>> + .channels_min = 1,
>> + .channels_max = 2,
>> + .rates = MAX98927_RATES,
>> + .formats = MAX98927_FORMATS,
>> + },
>> + .ops = &max98927_dai_ops,
>> + }
>> +};
>> +
>> +static int max98927_probe(struct snd_soc_codec *codec)
>> +{
>> + struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec);
>> +
>> + max98927->codec = codec;
>> + codec->control_data = max98927->regmap;
>> + codec->cache_bypass = 1;
>> +
>> + /* Software Reset */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0100_SOFT_RESET, MAX98927_SOFT_RESET);
>> +
>> + /* IV default slot configuration */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R001C_PCM_TX_HIZ_CTRL_A,
>> + 0xFF);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R001D_PCM_TX_HIZ_CTRL_B,
>> + 0xFF);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0025_PCM_TO_SPK_MONOMIX_A,
>> + 0x80);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0026_PCM_TO_SPK_MONOMIX_B,
>> + 0x1);
>> + /* Set inital volume (+13dB) */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0036_AMP_VOL_CTRL,
>> + 0x38);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R003C_SPK_GAIN,
>> + 0x05);
>> + /* Enable DC blocker */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0037_AMP_DSP_CFG,
>> + 0x03);
>> + /* Enable IMON VMON DC blocker */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R003F_MEAS_DSP_CFG,
>> + 0xF7);
>> + /* Boost Output Voltage & Current limit */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0040_BOOST_CTRL0,
>> + 0x1C);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0042_BOOST_CTRL1,
>> + 0x3E);
>> + /* Measurement ADC config */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0043_MEAS_ADC_CFG,
>> + 0x04);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0044_MEAS_ADC_BASE_MSB,
>> + 0x00);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0045_MEAS_ADC_BASE_LSB,
>> + 0x24);
>> + /* Brownout Level */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R007F_BROWNOUT_LVL4_AMP1_CTRL1,
>> + 0x06);
>> + /* Envelope Tracking configuration */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0082_ENV_TRACK_VOUT_HEADROOM,
>> + 0x08);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0086_ENV_TRACK_CTRL,
>> + 0x01);
>> + regmap_write(max98927->regmap,
>> + MAX98927_R0087_ENV_TRACK_BOOST_VOUT_READ,
>> + 0x10);
>> +
>> + /* voltage, current slot configuration */
>> + regmap_write(max98927->regmap,
>> + MAX98927_R001E_PCM_TX_CH_SRC_A,
>> + (max98927->i_l_slot<<MAX98927_PCM_TX_CH_SRC_A_I_SHIFT|
>> + max98927->v_l_slot)&0xFF);
>> +
>> + if (max98927->v_l_slot < 8) {
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001C_PCM_TX_HIZ_CTRL_A,
>> + 1 << max98927->v_l_slot, 0);
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001A_PCM_TX_EN_A,
>> + 1 << max98927->v_l_slot,
>> + 1 << max98927->v_l_slot);
>> + } else {
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001D_PCM_TX_HIZ_CTRL_B,
>> + 1 << (max98927->v_l_slot - 8), 0);
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001B_PCM_TX_EN_B,
>> + 1 << (max98927->v_l_slot - 8),
>> + 1 << (max98927->v_l_slot - 8));
>> + }
>> +
>> + if (max98927->i_l_slot < 8) {
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001C_PCM_TX_HIZ_CTRL_A,
>> + 1 << max98927->i_l_slot, 0);
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001A_PCM_TX_EN_A,
>> + 1 << max98927->i_l_slot,
>> + 1 << max98927->i_l_slot);
>> + } else {
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001D_PCM_TX_HIZ_CTRL_B,
>> + 1 << (max98927->i_l_slot - 8), 0);
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001B_PCM_TX_EN_B,
>> + 1 << (max98927->i_l_slot - 8),
>> + 1 << (max98927->i_l_slot - 8));
>> + }
>> +
>> + /* Set interleave mode */
>> + if (max98927->interleave_mode)
>> + regmap_update_bits(max98927->regmap,
>> + MAX98927_R001F_PCM_TX_CH_SRC_B,
>> + MAX98927_PCM_TX_CH_INTERLEAVE_MASK,
>> + MAX98927_PCM_TX_CH_INTERLEAVE_MASK);
>> + return 0;
>> +}
>> +
>> +static const struct snd_soc_codec_driver soc_codec_dev_max98927 = {
>> + .probe = max98927_probe,
>> + .component_driver = {
>> + .controls = max98927_snd_controls,
>> + .num_controls = ARRAY_SIZE(max98927_snd_controls),
>> + .dapm_widgets = max98927_dapm_widgets,
>> + .num_dapm_widgets = ARRAY_SIZE(max98927_dapm_widgets),
>> + .dapm_routes = max98927_audio_map,
>> + .num_dapm_routes = ARRAY_SIZE(max98927_audio_map),
>> + },
>> +};
>> +
>> +static const struct regmap_config max98927_regmap = {
>> + .reg_bits = 16,
>> + .val_bits = 8,
>> + .max_register = MAX98927_R01FF_REV_ID,
>> + .reg_defaults = max98927_reg,
>> + .num_reg_defaults = ARRAY_SIZE(max98927_reg),
>> + .readable_reg = max98927_readable_register,
>> + .volatile_reg = max98927_volatile_reg,
>> + .cache_type = REGCACHE_RBTREE,
>> +};
>> +
>> +static void max98927_slot_config(struct i2c_client *i2c,
>> + struct max98927_priv *max98927)
>> +{
>> + int value;
>> +
>> + if (!of_property_read_u32(i2c->dev.of_node,
>> + "vmon-slot-no", &value))
>> + max98927->v_l_slot = value & 0xF;
>> + else
>> + max98927->v_l_slot = 0;
>> + if (!of_property_read_u32(i2c->dev.of_node,
>> + "imon-slot-no", &value))
>> + max98927->i_l_slot = value & 0xF;
>> + else
>> + max98927->i_l_slot = 1;
>> +}
>> +
>> +static int max98927_i2c_probe(struct i2c_client *i2c,
>> + const struct i2c_device_id *id)
>> +{
>> +
>> + int ret = 0, value;
>> + int reg = 0;
>> + struct max98927_priv *max98927 = NULL;
>> +
>> + max98927 = devm_kzalloc(&i2c->dev,
>> + sizeof(*max98927), GFP_KERNEL);
>> +
>> + if (!max98927) {
>> + ret = -ENOMEM;
>> + return ret;
>> + }
>> + i2c_set_clientdata(i2c, max98927);
>> +
>> + /* update interleave mode info */
>> + if (!of_property_read_u32(i2c->dev.of_node,
>> + "interleave_mode", &value)) {
>> + if (value > 0)
>> + max98927->interleave_mode = 1;
>> + else
>> + max98927->interleave_mode = 0;
>> + } else
>> + max98927->interleave_mode = 0;
>> +
>> + /* regmap initialization */
>> + max98927->regmap
>> + = devm_regmap_init_i2c(i2c, &max98927_regmap);
>> + if (IS_ERR(max98927->regmap)) {
>> + ret = PTR_ERR(max98927->regmap);
>> + dev_err(&i2c->dev,
>> + "Failed to allocate regmap: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + /* Check Revision ID */
>> + ret = regmap_read(max98927->regmap,
>> + MAX98927_R01FF_REV_ID, ®);
>> + if (ret < 0) {
>> + dev_err(&i2c->dev,
>> + "Failed to read: 0x%02X\n", MAX98927_R01FF_REV_ID);
>> + return ret;
>> + }
>> + dev_info(&i2c->dev, "MAX98927 revisionID: 0x%02X\n", reg);
>> +
>> + /* voltage/current slot configuration */
>> + max98927_slot_config(i2c, max98927);
>> +
>> + /* codec registeration */
>> + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98927,
>> + max98927_dai, ARRAY_SIZE(max98927_dai));
>> + if (ret < 0)
>> + dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
>> +
>> + return ret;
>> +}
>> +
>> +static int max98927_i2c_remove(struct i2c_client *client)
>> +{
>> + snd_soc_unregister_codec(&client->dev);
>> + return 0;
>> +}
>> +
>> +static const struct i2c_device_id max98927_i2c_id[] = {
>> + { "max98927", 0},
>> + { },
>> +};
>> +
>> +MODULE_DEVICE_TABLE(i2c, max98927_i2c_id);
>> +
>> +#if defined(CONFIG_OF)
>> +static const struct of_device_id max98927_of_match[] = {
>> + { .compatible = "maxim,max98927", },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(of, max98927_of_match);
>> +#endif
>> +
>> +#ifdef CONFIG_ACPI
>> +static const struct acpi_device_id max98927_acpi_match[] = {
>> + { "MX98927", 0 },
>> + {},
>> +};
>> +MODULE_DEVICE_TABLE(acpi, max98927_acpi_match);
>> +#endif
>> +
>> +static struct i2c_driver max98927_i2c_driver = {
>> + .driver = {
>> + .name = "max98927",
>> + .of_match_table = of_match_ptr(max98927_of_match),
>> + .acpi_match_table = ACPI_PTR(max98927_acpi_match),
>> + .pm = NULL,
>> + },
>> + .probe = max98927_i2c_probe,
>> + .remove = max98927_i2c_remove,
>> + .id_table = max98927_i2c_id,
>> +};
>> +
>> +module_i2c_driver(max98927_i2c_driver)
>> +
>> +MODULE_DESCRIPTION("ALSA SoC MAX98927 driver");
>> +MODULE_AUTHOR("Ryan Lee <ryans.lee-zxKO94PEStzToO697jQleEEOCMrvLtNR@public.gmane.org>");
>> +MODULE_LICENSE("GPL");
>> diff --git a/sound/soc/codecs/max98927.h b/sound/soc/codecs/max98927.h
>> new file mode 100644
>> index 000000000000..ece6a608cbe1
>> --- /dev/null
>> +++ b/sound/soc/codecs/max98927.h
>> @@ -0,0 +1,272 @@
>> +/*
>> + * max98927.h -- MAX98927 ALSA Soc Audio driver
>> + *
>> + * Copyright 2013-15 Maxim Integrated Products
>> + * Author: Ryan Lee <ryans.lee-zxKO94PEStzToO697jQleEEOCMrvLtNR@public.gmane.org>
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms of the GNU General Public License as published by the
>> + * Free Software Foundation; either version 2 of the License, or (at your
>> + * option) any later version.
>> + *
>> + */
>> +#ifndef _MAX98927_H
>> +#define _MAX98927_H
>> +
>> +/* Register Values */
>> +#define MAX98927_R0001_INT_RAW1 0x0001
>> +#define MAX98927_R0002_INT_RAW2 0x0002
>> +#define MAX98927_R0003_INT_RAW3 0x0003
>> +#define MAX98927_R0004_INT_STATE1 0x0004
>> +#define MAX98927_R0005_INT_STATE2 0x0005
>> +#define MAX98927_R0006_INT_STATE3 0x0006
>> +#define MAX98927_R0007_INT_FLAG1 0x0007
>> +#define MAX98927_R0008_INT_FLAG2 0x0008
>> +#define MAX98927_R0009_INT_FLAG3 0x0009
>> +#define MAX98927_R000A_INT_EN1 0x000A
>> +#define MAX98927_R000B_INT_EN2 0x000B
>> +#define MAX98927_R000C_INT_EN3 0x000C
>> +#define MAX98927_R000D_INT_FLAG_CLR1 0x000D
>> +#define MAX98927_R000E_INT_FLAG_CLR2 0x000E
>> +#define MAX98927_R000F_INT_FLAG_CLR3 0x000F
>> +#define MAX98927_R0010_IRQ_CTRL 0x0010
>> +#define MAX98927_R0011_CLK_MON 0x0011
>> +#define MAX98927_R0012_WDOG_CTRL 0x0012
>> +#define MAX98927_R0013_WDOG_RST 0x0013
>> +#define MAX98927_R0014_MEAS_ADC_THERM_WARN_THRESH 0x0014
>> +#define MAX98927_R0015_MEAS_ADC_THERM_SHDN_THRESH 0x0015
>> +#define MAX98927_R0016_MEAS_ADC_THERM_HYSTERESIS 0x0016
>> +#define MAX98927_R0017_PIN_CFG 0x0017
>> +#define MAX98927_R0018_PCM_RX_EN_A 0x0018
>> +#define MAX98927_R0019_PCM_RX_EN_B 0x0019
>> +#define MAX98927_R001A_PCM_TX_EN_A 0x001A
>> +#define MAX98927_R001B_PCM_TX_EN_B 0x001B
>> +#define MAX98927_R001C_PCM_TX_HIZ_CTRL_A 0x001C
>> +#define MAX98927_R001D_PCM_TX_HIZ_CTRL_B 0x001D
>> +#define MAX98927_R001E_PCM_TX_CH_SRC_A 0x001E
>> +#define MAX98927_R001F_PCM_TX_CH_SRC_B 0x001F
>> +#define MAX98927_R0020_PCM_MODE_CFG 0x0020
>> +#define MAX98927_R0021_PCM_MASTER_MODE 0x0021
>> +#define MAX98927_R0022_PCM_CLK_SETUP 0x0022
>> +#define MAX98927_R0023_PCM_SR_SETUP1 0x0023
>> +#define MAX98927_R0024_PCM_SR_SETUP2 0x0024
>> +#define MAX98927_R0025_PCM_TO_SPK_MONOMIX_A 0x0025
>> +#define MAX98927_R0026_PCM_TO_SPK_MONOMIX_B 0x0026
>> +#define MAX98927_R0027_ICC_RX_EN_A 0x0027
>> +#define MAX98927_R0028_ICC_RX_EN_B 0x0028
>> +#define MAX98927_R002B_ICC_TX_EN_A 0x002B
>> +#define MAX98927_R002C_ICC_TX_EN_B 0x002C
>> +#define MAX98927_R002E_ICC_HIZ_MANUAL_MODE 0x002E
>> +#define MAX98927_R002F_ICC_TX_HIZ_EN_A 0x002F
>> +#define MAX98927_R0030_ICC_TX_HIZ_EN_B 0x0030
>> +#define MAX98927_R0031_ICC_LNK_EN 0x0031
>> +#define MAX98927_R0032_PDM_TX_EN 0x0032
>> +#define MAX98927_R0033_PDM_TX_HIZ_CTRL 0x0033
>> +#define MAX98927_R0034_PDM_TX_CTRL 0x0034
>> +#define MAX98927_R0035_PDM_RX_CTRL 0x0035
>> +#define MAX98927_R0036_AMP_VOL_CTRL 0x0036
>> +#define MAX98927_R0037_AMP_DSP_CFG 0x0037
>> +#define MAX98927_R0038_TONE_GEN_DC_CFG 0x0038
>> +#define MAX98927_R0039_DRE_CTRL 0x0039
>> +#define MAX98927_R003A_AMP_EN 0x003A
>> +#define MAX98927_R003B_SPK_SRC_SEL 0x003B
>> +#define MAX98927_R003C_SPK_GAIN 0x003C
>> +#define MAX98927_R003D_SSM_CFG 0x003D
>> +#define MAX98927_R003E_MEAS_EN 0x003E
>> +#define MAX98927_R003F_MEAS_DSP_CFG 0x003F
>> +#define MAX98927_R0040_BOOST_CTRL0 0x0040
>> +#define MAX98927_R0041_BOOST_CTRL3 0x0041
>> +#define MAX98927_R0042_BOOST_CTRL1 0x0042
>> +#define MAX98927_R0043_MEAS_ADC_CFG 0x0043
>> +#define MAX98927_R0044_MEAS_ADC_BASE_MSB 0x0044
>> +#define MAX98927_R0045_MEAS_ADC_BASE_LSB 0x0045
>> +#define MAX98927_R0046_ADC_CH0_DIVIDE 0x0046
>> +#define MAX98927_R0047_ADC_CH1_DIVIDE 0x0047
>> +#define MAX98927_R0048_ADC_CH2_DIVIDE 0x0048
>> +#define MAX98927_R0049_ADC_CH0_FILT_CFG 0x0049
>> +#define MAX98927_R004A_ADC_CH1_FILT_CFG 0x004A
>> +#define MAX98927_R004B_ADC_CH2_FILT_CFG 0x004B
>> +#define MAX98927_R004C_MEAS_ADC_CH0_READ 0x004C
>> +#define MAX98927_R004D_MEAS_ADC_CH1_READ 0x004D
>> +#define MAX98927_R004E_MEAS_ADC_CH2_READ 0x004E
>> +#define MAX98927_R0051_BROWNOUT_STATUS 0x0051
>> +#define MAX98927_R0052_BROWNOUT_EN 0x0052
>> +#define MAX98927_R0053_BROWNOUT_INFINITE_HOLD 0x0053
>> +#define MAX98927_R0054_BROWNOUT_INFINITE_HOLD_CLR 0x0054
>> +#define MAX98927_R0055_BROWNOUT_LVL_HOLD 0x0055
>> +#define MAX98927_R005A_BROWNOUT_LVL1_THRESH 0x005A
>> +#define MAX98927_R005B_BROWNOUT_LVL2_THRESH 0x005B
>> +#define MAX98927_R005C_BROWNOUT_LVL3_THRESH 0x005C
>> +#define MAX98927_R005D_BROWNOUT_LVL4_THRESH 0x005D
>> +#define MAX98927_R005E_BROWNOUT_THRESH_HYSTERYSIS 0x005E
>> +#define MAX98927_R005F_BROWNOUT_AMP_LIMITER_ATK_REL 0x005F
>> +#define MAX98927_R0060_BROWNOUT_AMP_GAIN_ATK_REL 0x0060
>> +#define MAX98927_R0061_BROWNOUT_AMP1_CLIP_MODE 0x0061
>> +#define MAX98927_R0072_BROWNOUT_LVL1_CUR_LIMIT 0x0072
>> +#define MAX98927_R0073_BROWNOUT_LVL1_AMP1_CTRL1 0x0073
>> +#define MAX98927_R0074_BROWNOUT_LVL1_AMP1_CTRL2 0x0074
>> +#define MAX98927_R0075_BROWNOUT_LVL1_AMP1_CTRL3 0x0075
>> +#define MAX98927_R0076_BROWNOUT_LVL2_CUR_LIMIT 0x0076
>> +#define MAX98927_R0077_BROWNOUT_LVL2_AMP1_CTRL1 0x0077
>> +#define MAX98927_R0078_BROWNOUT_LVL2_AMP1_CTRL2 0x0078
>> +#define MAX98927_R0079_BROWNOUT_LVL2_AMP1_CTRL3 0x0079
>> +#define MAX98927_R007A_BROWNOUT_LVL3_CUR_LIMIT 0x007A
>> +#define MAX98927_R007B_BROWNOUT_LVL3_AMP1_CTRL1 0x007B
>> +#define MAX98927_R007C_BROWNOUT_LVL3_AMP1_CTRL2 0x007C
>> +#define MAX98927_R007D_BROWNOUT_LVL3_AMP1_CTRL3 0x007D
>> +#define MAX98927_R007E_BROWNOUT_LVL4_CUR_LIMIT 0x007E
>> +#define MAX98927_R007F_BROWNOUT_LVL4_AMP1_CTRL1 0x007F
>> +#define MAX98927_R0080_BROWNOUT_LVL4_AMP1_CTRL2 0x0080
>> +#define MAX98927_R0081_BROWNOUT_LVL4_AMP1_CTRL3 0x0081
>> +#define MAX98927_R0082_ENV_TRACK_VOUT_HEADROOM 0x0082
>> +#define MAX98927_R0083_ENV_TRACK_BOOST_VOUT_DELAY 0x0083
>> +#define MAX98927_R0084_ENV_TRACK_REL_RATE 0x0084
>> +#define MAX98927_R0085_ENV_TRACK_HOLD_RATE 0x0085
>> +#define MAX98927_R0086_ENV_TRACK_CTRL 0x0086
>> +#define MAX98927_R0087_ENV_TRACK_BOOST_VOUT_READ 0x0087
>> +#define MAX98927_R00FF_GLOBAL_SHDN 0x00FF
>> +#define MAX98927_R0100_SOFT_RESET 0x0100
>> +#define MAX98927_R01FF_REV_ID 0x01FF
>> +
>> +/* MAX98927_R0018_PCM_RX_EN_A */
>> +#define MAX98927_PCM_RX_CH0_EN (0x1 << 0)
>> +#define MAX98927_PCM_RX_CH1_EN (0x1 << 1)
>> +#define MAX98927_PCM_RX_CH2_EN (0x1 << 2)
>> +#define MAX98927_PCM_RX_CH3_EN (0x1 << 3)
>> +#define MAX98927_PCM_RX_CH4_EN (0x1 << 4)
>> +#define MAX98927_PCM_RX_CH5_EN (0x1 << 5)
>> +#define MAX98927_PCM_RX_CH6_EN (0x1 << 6)
>> +#define MAX98927_PCM_RX_CH7_EN (0x1 << 7)
>> +
>> +/* MAX98927_R001A_PCM_TX_EN_A */
>> +#define MAX98927_PCM_TX_CH0_EN (0x1 << 0)
>> +#define MAX98927_PCM_TX_CH1_EN (0x1 << 1)
>> +#define MAX98927_PCM_TX_CH2_EN (0x1 << 2)
>> +#define MAX98927_PCM_TX_CH3_EN (0x1 << 3)
>> +#define MAX98927_PCM_TX_CH4_EN (0x1 << 4)
>> +#define MAX98927_PCM_TX_CH5_EN (0x1 << 5)
>> +#define MAX98927_PCM_TX_CH6_EN (0x1 << 6)
>> +#define MAX98927_PCM_TX_CH7_EN (0x1 << 7)
>> +
>> +/* MAX98927_R001E_PCM_TX_CH_SRC_A */
>> +#define MAX98927_PCM_TX_CH_SRC_A_V_SHIFT (0)
>> +#define MAX98927_PCM_TX_CH_SRC_A_I_SHIFT (4)
>> +
>> +/* MAX98927_R001F_PCM_TX_CH_SRC_B */
>> +#define MAX98927_PCM_TX_CH_INTERLEAVE_MASK (0x1 << 5)
>> +
>> +/* MAX98927_R0020_PCM_MODE_CFG */
>> +#define MAX98927_PCM_MODE_CFG_PCM_BCLKEDGE (0x1 << 2)
>> +#define MAX98927_PCM_MODE_CFG_FORMAT_MASK (0x7 << 3)
>> +#define MAX98927_PCM_MODE_CFG_FORMAT_SHIFT (3)
>> +#define MAX98927_PCM_FORMAT_I2S (0x0 << 0)
>> +#define MAX98927_PCM_FORMAT_LJ (0x1 << 0)
>> +
>> +#define MAX98927_PCM_MODE_CFG_CHANSZ_MASK (0x3 << 6)
>> +#define MAX98927_PCM_MODE_CFG_CHANSZ_16 (0x1 << 6)
>> +#define MAX98927_PCM_MODE_CFG_CHANSZ_24 (0x2 << 6)
>> +#define MAX98927_PCM_MODE_CFG_CHANSZ_32 (0x3 << 6)
>> +
>> +/* MAX98927_R0021_PCM_MASTER_MODE */
>> +#define MAX98927_PCM_MASTER_MODE_MASK (0x3 << 0)
>> +#define MAX98927_PCM_MASTER_MODE_SLAVE (0x0 << 0)
>> +#define MAX98927_PCM_MASTER_MODE_MASTER (0x3 << 0)
>> +
>> +#define MAX98927_PCM_MASTER_MODE_MCLK_MASK (0xF << 2)
>> +#define MAX98927_PCM_MASTER_MODE_MCLK_RATE_SHIFT (2)
>> +
>> +/* MAX98927_R0022_PCM_CLK_SETUP */
>> +#define MAX98927_PCM_CLK_SETUP_BSEL_MASK (0xF << 0)
>> +
>> +/* MAX98927_R0023_PCM_SR_SETUP1 */
>> +#define MAX98927_PCM_SR_SET1_SR_MASK (0xF << 0)
>> +
>> +#define MAX98927_PCM_SR_SET1_SR_8000 (0x0 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_11025 (0x1 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_12000 (0x2 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_16000 (0x3 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_22050 (0x4 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_24000 (0x5 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_32000 (0x6 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_44100 (0x7 << 0)
>> +#define MAX98927_PCM_SR_SET1_SR_48000 (0x8 << 0)
>> +
>> +/* MAX98927_R0024_PCM_SR_SETUP2 */
>> +#define MAX98927_PCM_SR_SET2_SR_MASK (0xF << 4)
>> +#define MAX98927_PCM_SR_SET2_SR_SHIFT (4)
>> +#define MAX98927_PCM_SR_SET2_IVADC_SR_MASK (0xf << 0)
>> +
>> +/* MAX98927_R0025_PCM_TO_SPK_MONOMIX_A */
>> +#define MAX98927_PCM_TO_SPK_MONOMIX_CFG_MASK (0x3 << 6)
>> +#define MAX98927_PCM_TO_SPK_MONOMIX_CFG_SHIFT (6)
>> +
>> +/* MAX98927_R0035_PDM_RX_CTRL */
>> +#define MAX98927_PDM_RX_EN_MASK (0x1 << 0)
>> +
>> +/* MAX98927_R0036_AMP_VOL_CTRL */
>> +#define MAX98927_AMP_VOL_SEL (0x1 << 7)
>> +#define MAX98927_AMP_VOL_SEL_WIDTH (1)
>> +#define MAX98927_AMP_VOL_SEL_SHIFT (7)
>> +#define MAX98927_AMP_VOL_MASK (0x7f << 0)
>> +#define MAX98927_AMP_VOL_WIDTH (7)
>> +#define MAX98927_AMP_VOL_SHIFT (0)
>> +
>> +/* MAX98927_R0037_AMP_DSP_CFG */
>> +#define MAX98927_AMP_DSP_CFG_DCBLK_EN (0x1 << 0)
>> +#define MAX98927_AMP_DSP_CFG_DITH_EN (0x1 << 1)
>> +#define MAX98927_AMP_DSP_CFG_RMP_BYPASS (0x1 << 4)
>> +#define MAX98927_AMP_DSP_CFG_DAC_INV (0x1 << 5)
>> +#define MAX98927_AMP_DSP_CFG_RMP_SHIFT (4)
>> +
>> +/* MAX98927_R0039_DRE_CTRL */
>> +#define MAX98927_DRE_CTRL_DRE_EN (0x1 << 0)
>> +#define MAX98927_DRE_EN_SHIFT 0x1
>> +
>> +/* MAX98927_R003A_AMP_EN */
>> +#define MAX98927_AMP_EN_MASK (0x1 << 0)
>> +
>> +/* MAX98927_R003B_SPK_SRC_SEL */
>> +#define MAX98927_SPK_SRC_MASK (0x3 << 0)
>> +
>> +/* MAX98927_R003C_SPK_GAIN */
>> +#define MAX98927_SPK_PCM_GAIN_MASK (0x7 << 0)
>> +#define MAX98927_SPK_PDM_GAIN_MASK (0x7 << 4)
>> +#define MAX98927_SPK_GAIN_WIDTH (3)
>> +
>> +/* MAX98927_R003E_MEAS_EN */
>> +#define MAX98927_MEAS_V_EN (0x1 << 0)
>> +#define MAX98927_MEAS_I_EN (0x1 << 1)
>> +
>> +/* MAX98927_R0040_BOOST_CTRL0 */
>> +#define MAX98927_BOOST_CTRL0_VOUT_MASK (0x1f << 0)
>> +#define MAX98927_BOOST_CTRL0_PVDD_MASK (0x1 << 7)
>> +#define MAX98927_BOOST_CTRL0_PVDD_EN_SHIFT (7)
>> +
>> +/* MAX98927_R0052_BROWNOUT_EN */
>> +#define MAX98927_BROWNOUT_BDE_EN (0x1 << 0)
>> +#define MAX98927_BROWNOUT_AMP_EN (0x1 << 1)
>> +#define MAX98927_BROWNOUT_DSP_EN (0x1 << 2)
>> +#define MAX98927_BROWNOUT_DSP_SHIFT (2)
>> +
>> +/* MAX98927_R0100_SOFT_RESET */
>> +#define MAX98927_SOFT_RESET (0x1 << 0)
>> +
>> +/* MAX98927_R00FF_GLOBAL_SHDN */
>> +#define MAX98927_GLOBAL_EN_MASK (0x1 << 0)
>> +
>> +struct max98927_priv {
>> + struct regmap *regmap;
>> + struct snd_soc_codec *codec;
>> + struct max98927_pdata *pdata;
>> + unsigned int spk_gain;
>> + unsigned int sysclk;
>> + unsigned int v_l_slot;
>> + unsigned int i_l_slot;
>> + bool interleave_mode;
>> + unsigned int ch_size;
>> + unsigned int rate;
>> + unsigned int iface;
>> + unsigned int master;
>> + unsigned int digital_gain;
>> +};
>> +#endif
>> --
>> 2.11.0
>>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox