[LEDE-DEV] [PATCH] brcm2708: backport upstream thermal driver

2017-04-01 Thread Rafał Miłecki
From: Rafał Miłecki 

Signed-off-by: Rafał Miłecki 
---
 ...cm2835-add-thermal-driver-for-bcm2835-SoC.patch | 365 +
 1 file changed, 365 insertions(+)
 create mode 100644 
target/linux/brcm2708/patches-4.9/081-0001-thermal-bcm2835-add-thermal-driver-for-bcm2835-SoC.patch

diff --git 
a/target/linux/brcm2708/patches-4.9/081-0001-thermal-bcm2835-add-thermal-driver-for-bcm2835-SoC.patch
 
b/target/linux/brcm2708/patches-4.9/081-0001-thermal-bcm2835-add-thermal-driver-for-bcm2835-SoC.patch
new file mode 100644
index 00..a11c542913
--- /dev/null
+++ 
b/target/linux/brcm2708/patches-4.9/081-0001-thermal-bcm2835-add-thermal-driver-for-bcm2835-SoC.patch
@@ -0,0 +1,365 @@
+From bcb7dd9ef206f7d646ed8dac6fe7772083714253 Mon Sep 17 00:00:00 2001
+From: Stefan Wahren 
+Date: Fri, 31 Mar 2017 20:03:06 +
+Subject: [PATCH] thermal: bcm2835: add thermal driver for bcm2835 SoC
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Add basic thermal driver for bcm2835 SoC.
+
+This driver currently make sure that tsense HW block is set up
+correctly.
+
+Tested-by: Rafał Miłecki 
+Signed-off-by: Martin Sperl 
+Signed-off-by: Stefan Wahren 
+Acked-by: Eric Anholt 
+Acked-by: Eduardo Valentin 
+Signed-off-by: Eduardo Valentin 
+---
+ drivers/thermal/Kconfig   |   8 +
+ drivers/thermal/Makefile  |   1 +
+ drivers/thermal/bcm2835_thermal.c | 314 ++
+ 3 files changed, 323 insertions(+)
+ create mode 100644 drivers/thermal/bcm2835_thermal.c
+
+--- a/drivers/thermal/Kconfig
 b/drivers/thermal/Kconfig
+@@ -434,4 +434,12 @@ depends on (ARCH_QCOM && OF) || COMPILE_
+ source "drivers/thermal/qcom/Kconfig"
+ endmenu
+ 
++config BCM2835_THERMAL
++  tristate "Thermal sensors on bcm2835 SoC"
++  depends on ARCH_BCM2835 || COMPILE_TEST
++  depends on HAS_IOMEM
++  depends on THERMAL_OF
++  help
++Support for thermal sensors on Broadcom bcm2835 SoCs.
++
+ endif
+--- a/drivers/thermal/Makefile
 b/drivers/thermal/Makefile
+@@ -55,3 +55,4 @@ obj-$(CONFIG_TEGRA_SOCTHERM) += tegra/
+ obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
+ obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o
+ obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o
++obj-$(CONFIG_BCM2835_THERMAL) += bcm2835_thermal.o
+--- /dev/null
 b/drivers/thermal/bcm2835_thermal.c
+@@ -0,0 +1,314 @@
++/*
++ * Driver for Broadcom BCM2835 SoC temperature sensor
++ *
++ * Copyright (C) 2016 Martin Sperl
++ *
++ * 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.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ */
++
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++
++#define BCM2835_TS_TSENSCTL   0x00
++#define BCM2835_TS_TSENSSTAT  0x04
++
++#define BCM2835_TS_TSENSCTL_PRWDW BIT(0)
++#define BCM2835_TS_TSENSCTL_RSTB  BIT(1)
++
++/*
++ * bandgap reference voltage in 6 mV increments
++ * 000b = 1178 mV, 001b = 1184 mV, ... 111b = 1220 mV
++ */
++#define BCM2835_TS_TSENSCTL_CTRL_BITS 3
++#define BCM2835_TS_TSENSCTL_CTRL_SHIFT2
++#define BCM2835_TS_TSENSCTL_CTRL_MASK \
++  GENMASK(BCM2835_TS_TSENSCTL_CTRL_BITS + \
++  BCM2835_TS_TSENSCTL_CTRL_SHIFT - 1, \
++  BCM2835_TS_TSENSCTL_CTRL_SHIFT)
++#define BCM2835_TS_TSENSCTL_CTRL_DEFAULT  1
++#define BCM2835_TS_TSENSCTL_EN_INTBIT(5)
++#define BCM2835_TS_TSENSCTL_DIRECTBIT(6)
++#define BCM2835_TS_TSENSCTL_CLR_INT   BIT(7)
++#define BCM2835_TS_TSENSCTL_THOLD_SHIFT   8
++#define BCM2835_TS_TSENSCTL_THOLD_BITS10
++#define BCM2835_TS_TSENSCTL_THOLD_MASK \
++  GENMASK(BCM2835_TS_TSENSCTL_THOLD_BITS + \
++  BCM2835_TS_TSENSCTL_THOLD_SHIFT - 1, \
++  BCM2835_TS_TSENSCTL_THOLD_SHIFT)
++/*
++ * time how long the block to be asserted in reset
++ * which based on a clock counter (TSENS clock assumed)
++ */
++#define BCM2835_TS_TSENSCTL_RSTDELAY_SHIFT18
++#define BCM2835_TS_TSENSCTL_RSTDELAY_BITS 8
++#define BCM2835_TS_TSENSCTL_REGULEN   BIT(26)
++
++#define BCM2835_TS_TSENSSTAT_DATA_BITS10
++#define BCM2835_TS_TSENSSTAT_DATA_SHIFT 

[LEDE-DEV] [PATCH] brcm2708: backport upstream sdhost controller driver

2017-04-01 Thread Rafał Miłecki
From: Rafał Miłecki 

Signed-off-by: Rafał Miłecki 
---
 target/linux/brcm2708/bcm2708/config-4.9   |1 +
 ...-Add-new-driver-for-the-sdhost-controller.patch | 1536 
 ...-Fix-possible-NULL-ptr-dereference-in-bcm.patch |   30 +
 ...-rename-Kconfig-symbol-to-avoid-downstrea.patch |   40 +
 4 files changed, 1607 insertions(+)
 create mode 100644 
target/linux/brcm2708/patches-4.9/080-0001-mmc-bcm2835-Add-new-driver-for-the-sdhost-controller.patch
 create mode 100644 
target/linux/brcm2708/patches-4.9/080-0002-mmc-bcm2835-Fix-possible-NULL-ptr-dereference-in-bcm.patch
 create mode 100644 
target/linux/brcm2708/patches-4.9/080-0100-mmc-bcm2835-rename-Kconfig-symbol-to-avoid-downstrea.patch

diff --git a/target/linux/brcm2708/bcm2708/config-4.9 
b/target/linux/brcm2708/bcm2708/config-4.9
index c1bed074c3..76dd1fde18 100644
--- a/target/linux/brcm2708/bcm2708/config-4.9
+++ b/target/linux/brcm2708/bcm2708/config-4.9
@@ -251,6 +251,7 @@ CONFIG_MMC_BCM2835=y
 CONFIG_MMC_BCM2835_DMA=y
 CONFIG_MMC_BCM2835_PIO_DMA_BARRIER=2
 CONFIG_MMC_BCM2835_SDHOST=y
+# CONFIG_MMC_BCM2835_UPSTREAM is not set
 CONFIG_MMC_BLOCK=y
 CONFIG_MMC_BLOCK_MINORS=32
 CONFIG_MMC_SDHCI=y
diff --git 
a/target/linux/brcm2708/patches-4.9/080-0001-mmc-bcm2835-Add-new-driver-for-the-sdhost-controller.patch
 
b/target/linux/brcm2708/patches-4.9/080-0001-mmc-bcm2835-Add-new-driver-for-the-sdhost-controller.patch
new file mode 100644
index 00..2c0238cad9
--- /dev/null
+++ 
b/target/linux/brcm2708/patches-4.9/080-0001-mmc-bcm2835-Add-new-driver-for-the-sdhost-controller.patch
@@ -0,0 +1,1536 @@
+From a7d3e315a02c3154c38d09e51fc9461ba2cac396 Mon Sep 17 00:00:00 2001
+From: Eric Anholt 
+Date: Wed, 8 Mar 2017 10:19:03 +0100
+Subject: [PATCH] mmc: bcm2835: Add new driver for the sdhost controller.
+
+The 2835 has two SD controllers: The Arasan sdhci controller (supported
+by the iproc driver) and a custom sdhost controller.  This patch adds a
+driver for the latter.
+
+The sdhci controller supports both sdcard and sdio.  The sdhost
+controller supports the sdcard only, but has better performance.  Also
+note that the rpi3 has sdio wifi, so driving the sdcard with the sdhost
+controller allows to use the sdhci controller for wifi support.
+
+The configuration is done by devicetree via pin muxing.  Both SD
+controller are available on the same pins (2 pin groups = pin 22 to 27 +
+pin 48 to 53).  So it's possible to use both SD controllers at the same
+time with different pin groups.
+
+The code was originally written by Phil Elwell in the downstream
+Rasbperry Pi tree.   In preparation for the upstream merge it was
+cleaned up and the code base was moderized by Eric Anholt, Stefan
+Wahren and Gerd Hoffmann.
+
+Signed-off-by: Eric Anholt 
+Signed-off-by: Stefan Wahren 
+Signed-off-by: Gerd Hoffmann 
+Signed-off-by: Ulf Hansson 
+---
+ drivers/mmc/host/Kconfig   |   14 +
+ drivers/mmc/host/Makefile  |1 +
+ drivers/mmc/host/bcm2835.c | 1465 
+ 3 files changed, 1480 insertions(+)
+ create mode 100644 drivers/mmc/host/bcm2835.c
+
+--- a/drivers/mmc/host/Kconfig
 b/drivers/mmc/host/Kconfig
+@@ -769,6 +769,20 @@ config MMC_TOSHIBA_PCI
+   depends on PCI
+   help
+ 
++config MMC_BCM2835
++  tristate "Broadcom BCM2835 SDHOST MMC Controller support"
++  depends on ARCH_BCM2835 || COMPILE_TEST
++  depends on HAS_DMA
++  help
++This selects the BCM2835 SDHOST MMC controller. If you have
++a BCM2835 platform with SD or MMC devices, say Y or M here.
++
++Note that the BCM2835 has two SD controllers: The Arasan
++sdhci controller (supported by MMC_SDHCI_IPROC) and a custom
++sdhost controller (supported by this driver).
++
++If unsure, say N.
++
+ config MMC_MTK
+   tristate "MediaTek SD/MMC Card Interface support"
+   depends on HAS_DMA
+--- a/drivers/mmc/host/Makefile
 b/drivers/mmc/host/Makefile
+@@ -57,6 +57,7 @@ obj-$(CONFIG_MMC_MOXART) += moxart-mmc.o
+ obj-$(CONFIG_MMC_SUNXI)   += sunxi-mmc.o
+ obj-$(CONFIG_MMC_USDHI6ROL0)  += usdhi6rol0.o
+ obj-$(CONFIG_MMC_TOSHIBA_PCI) += toshsd.o
++obj-$(CONFIG_MMC_BCM2835) += bcm2835.o
+ 
+ obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o
+ obj-$(CONFIG_MMC_REALTEK_USB) += rtsx_usb_sdmmc.o
+--- /dev/null
 b/drivers/mmc/host/bcm2835.c
+@@ -0,0 +1,1465 @@
++/*
++ * bcm2835 sdhost driver.
++ *
++ * The 2835 has two SD controllers: The Arasan sdhci controller
++ * (supported by the iproc driver) and a custom sdhost controller
++ * (supported by this driver).
++ *
++ * The sdhci controller supports both sdcard and sdio.  The sdhost
++ * controller supports the sdcard only, but has better performance.
++ * Also note that the rpi3 has sdio wifi, so driving the sdcard with
++ * the sdhost controller allows 

Re: [LEDE-DEV] [PATCH] ar71xx: add Engenius ENH200EXT support

2017-04-01 Thread Paul Oranje
See comments/questions inline below.
-- 
Paul Oranje


> Op 1 apr. 2017, om 02:00 heeft Daniel Golle  het 
> volgende geschreven:
> 
> Hi Paul,
> 
> On Fri, Mar 31, 2017 at 10:38:39PM +0200, Paul Oranje wrote:
>> This POE access point suited for outside usage needs an external antenna.
>> According FCC documentation the ENH200EXT (needs external antenna) and the 
>> ENH200 (with internal antenna) are electrically equal to the Allnet ALL0258N.
>> 
>> The stock image does not allow install of a LEDE factory image, but an 
>> initramfs image (lede-ar71xx-generic-enh200ext-initramfs-uImage.bin) can be 
>> loaded via u-boot recovery procedure (long press reset at power-on until all 
>> LEDS burn). The u-boot recovery procedure boots an image named 
>> vmlinux-art-ramdisk from 192.168.1.101.
>> Once booted the sysupgrade image can be flashed from the booted iniramfs 
>> LEDE.
>> 
>> Only abnormality is that for some unknown reason the txpower cannot be set 
>> higher than 16 dBm whereas the Engenius stock firmware allows a maximum of 
>> 27 dBm.
> 
> Yes, difference is software only. ALL0258N came with OpenWrt
> pre-flashed, hence we contributed the needed bits upstream. Also went
> through ODM QA with OpenWrt, so EEPROM might not be identical for
> ENH200 and ALL0258N (the latter was intended to run OpenWrt with ath9k
> as well as Atheros SDK's proprietary driver).
Could the lower maximum txpower be the result of not running with the 
proprietary driver ?
> 
>> 
>> Signed-off-by: Paul Oranje 
>> ---
>> package/boot/uboot-envtools/files/ar71xx   |  1 +
>> target/linux/ar71xx/base-files/etc/board.d/01_leds |  3 +-
>> .../linux/ar71xx/base-files/etc/board.d/02_network |  1 +
>> target/linux/ar71xx/base-files/lib/ar71xx.sh   |  3 +
>> .../ar71xx/base-files/lib/upgrade/platform.sh  |  6 +-
>> target/linux/ar71xx/config-4.4 |  1 +
>> .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  9 +++
>> target/linux/ar71xx/files/arch/mips/ath79/Makefile |  1 +
>> .../ar71xx/files/arch/mips/ath79/mach-enh200ext.c  | 89 
>> ++
> ^^^
> Please merge this with mach-all0258n.c so we don't have tons of
> redundant code. Make them share most of the setup code, maybe
> parametrisize the LEDs so you can pass a string and then just have
> two MIPS_MACHINE lines at the bottom of the file. Take a look at
> various mach-tl-*.c files which usually are for several similar
> models each.
What would the source file with the merged support be named, mach-all0258n.c, 
mach-enh20x.c, or … ?

A few more questions:
Apart from this file and putting the dev’s make stances in generic.mk, which of 
the other files that were patched with the v1 patch should be handled 
differently ?
When changing the make stances, what is a good way to rebuild the config 
without going through make clean (my build laptop sports just 3 GB and an Intel 
C2D, so a complete build does take quite some time) ?


> 
> Cheers
> 
> Daniel
> 
> ___
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev