Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/5] net: thunderx: Program LMAC credits based on MTU
From: sunil.kovvuri at gmail.com @ 2016-11-14 10:54 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1479120886-13425-1-git-send-email-sunil.kovvuri@gmail.com>

From: Sunil Goutham <sgoutham@cavium.com>

Programming LMAC credits taking 9K frame size by default is incorrect
as for an interface which is one of the many on the same BGX/QLM
no of credits available will be less as Tx FIFO will be divided
across all interfaces. So let's say a BGX with 40G interface and another
BGX with multiple 10G, bandwidth of 10G interfaces will be effected when
traffic is running on both 40G and 10G interfaces simultaneously.

This patch fixes this issue by programming credits based on netdev's MTU.
Also fixed configuring MTU to HW and added CQE counter for pkts which
exceed this value.

Signed-off-by: Sunil Goutham <sgoutham@cavium.com>
---
 drivers/net/ethernet/cavium/thunder/nic.h          |  3 +-
 drivers/net/ethernet/cavium/thunder/nic_main.c     | 36 +++++++++++++-------
 drivers/net/ethernet/cavium/thunder/nic_reg.h      |  1 +
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   | 38 ++++++++++++----------
 drivers/net/ethernet/cavium/thunder/nicvf_queues.c |  3 ++
 drivers/net/ethernet/cavium/thunder/nicvf_queues.h |  2 ++
 6 files changed, 53 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nic.h b/drivers/net/ethernet/cavium/thunder/nic.h
index 3042610..cd2d379 100644
--- a/drivers/net/ethernet/cavium/thunder/nic.h
+++ b/drivers/net/ethernet/cavium/thunder/nic.h
@@ -47,7 +47,7 @@
 
 /* Min/Max packet size */
 #define	NIC_HW_MIN_FRS			64
-#define	NIC_HW_MAX_FRS			9200 /* 9216 max packet including FCS */
+#define	NIC_HW_MAX_FRS			9190 /* Excluding L2 header and FCS */
 
 /* Max pkinds */
 #define	NIC_MAX_PKIND			16
@@ -282,7 +282,6 @@ struct nicvf {
 
 	u8			node;
 	u8			cpi_alg;
-	u16			mtu;
 	bool			link_up;
 	u8			duplex;
 	u32			speed;
diff --git a/drivers/net/ethernet/cavium/thunder/nic_main.c b/drivers/net/ethernet/cavium/thunder/nic_main.c
index 2bbf4cb..85c9e62 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nic_main.c
@@ -11,6 +11,7 @@
 #include <linux/pci.h>
 #include <linux/etherdevice.h>
 #include <linux/of.h>
+#include <linux/if_vlan.h>
 
 #include "nic_reg.h"
 #include "nic.h"
@@ -260,18 +261,31 @@ static void nic_get_bgx_stats(struct nicpf *nic, struct bgx_stats_msg *bgx)
 /* Update hardware min/max frame size */
 static int nic_update_hw_frs(struct nicpf *nic, int new_frs, int vf)
 {
-	if ((new_frs > NIC_HW_MAX_FRS) || (new_frs < NIC_HW_MIN_FRS)) {
-		dev_err(&nic->pdev->dev,
-			"Invalid MTU setting from VF%d rejected, should be between %d and %d\n",
-			   vf, NIC_HW_MIN_FRS, NIC_HW_MAX_FRS);
+	int bgx, lmac, lmac_cnt;
+	u64 lmac_credits;
+
+	if ((new_frs > NIC_HW_MAX_FRS) || (new_frs < NIC_HW_MIN_FRS))
 		return 1;
-	}
-	new_frs += ETH_HLEN;
-	if (new_frs <= nic->pkind.maxlen)
-		return 0;
 
-	nic->pkind.maxlen = new_frs;
-	nic_reg_write(nic, NIC_PF_PKIND_0_15_CFG, *(u64 *)&nic->pkind);
+	bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
+	lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
+	lmac += bgx * MAX_LMAC_PER_BGX;
+
+	new_frs += VLAN_ETH_HLEN + ETH_FCS_LEN + 4;
+
+	/* Update corresponding LMAC credits */
+	lmac_cnt = bgx_get_lmac_count(nic->node, bgx);
+	lmac_credits = nic_reg_read(nic, NIC_PF_LMAC_0_7_CREDIT + (lmac * 8));
+	lmac_credits &= ~(0xFFFFFULL << 12);
+	lmac_credits |= (((((48 * 1024) / lmac_cnt) - new_frs) / 16) << 12);
+	nic_reg_write(nic, NIC_PF_LMAC_0_7_CREDIT + (lmac * 8), lmac_credits);
+
+	/* Enforce MTU in HW
+	 * This config is supported only from 88xx pass 2.0 onwards.
+	 */
+	if (!pass1_silicon(nic->pdev))
+		nic_reg_write(nic,
+			      NIC_PF_LMAC_0_7_CFG2 + (lmac * 8), new_frs);
 	return 0;
 }
 
@@ -464,7 +478,7 @@ static int nic_init_hw(struct nicpf *nic)
 
 	/* PKIND configuration */
 	nic->pkind.minlen = 0;
-	nic->pkind.maxlen = NIC_HW_MAX_FRS + ETH_HLEN;
+	nic->pkind.maxlen = NIC_HW_MAX_FRS + VLAN_ETH_HLEN + ETH_FCS_LEN + 4;
 	nic->pkind.lenerr_en = 1;
 	nic->pkind.rx_hdr = 0;
 	nic->pkind.hdr_sl = 0;
diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h
index edf779f..80d4633 100644
--- a/drivers/net/ethernet/cavium/thunder/nic_reg.h
+++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h
@@ -106,6 +106,7 @@
 #define   NIC_PF_MPI_0_2047_CFG			(0x210000)
 #define   NIC_PF_RSSI_0_4097_RQ			(0x220000)
 #define   NIC_PF_LMAC_0_7_CFG			(0x240000)
+#define   NIC_PF_LMAC_0_7_CFG2			(0x240100)
 #define   NIC_PF_LMAC_0_7_SW_XOFF		(0x242000)
 #define   NIC_PF_LMAC_0_7_CREDIT		(0x244000)
 #define   NIC_PF_CHAN_0_255_TX_CFG		(0x400000)
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 45a13f7..8f83361 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -1189,6 +1189,17 @@ int nicvf_stop(struct net_device *netdev)
 	return 0;
 }
 
+static int nicvf_update_hw_max_frs(struct nicvf *nic, int mtu)
+{
+	union nic_mbx mbx = {};
+
+	mbx.frs.msg = NIC_MBOX_MSG_SET_MAX_FRS;
+	mbx.frs.max_frs = mtu;
+	mbx.frs.vf_id = nic->vf_id;
+
+	return nicvf_send_msg_to_pf(nic, &mbx);
+}
+
 int nicvf_open(struct net_device *netdev)
 {
 	int err, qidx;
@@ -1196,8 +1207,6 @@ int nicvf_open(struct net_device *netdev)
 	struct queue_set *qs = nic->qs;
 	struct nicvf_cq_poll *cq_poll = NULL;
 
-	nic->mtu = netdev->mtu;
-
 	netif_carrier_off(netdev);
 
 	err = nicvf_register_misc_interrupt(nic);
@@ -1248,9 +1257,12 @@ int nicvf_open(struct net_device *netdev)
 	if (nic->sqs_mode)
 		nicvf_get_primary_vf_struct(nic);
 
-	/* Configure receive side scaling */
-	if (!nic->sqs_mode)
+	/* Configure receive side scaling and MTU */
+	if (!nic->sqs_mode) {
 		nicvf_rss_init(nic);
+		if (nicvf_update_hw_max_frs(nic, netdev->mtu))
+			goto cleanup;
+	}
 
 	err = nicvf_register_interrupts(nic);
 	if (err)
@@ -1297,17 +1309,6 @@ int nicvf_open(struct net_device *netdev)
 	return err;
 }
 
-static int nicvf_update_hw_max_frs(struct nicvf *nic, int mtu)
-{
-	union nic_mbx mbx = {};
-
-	mbx.frs.msg = NIC_MBOX_MSG_SET_MAX_FRS;
-	mbx.frs.max_frs = mtu;
-	mbx.frs.vf_id = nic->vf_id;
-
-	return nicvf_send_msg_to_pf(nic, &mbx);
-}
-
 static int nicvf_change_mtu(struct net_device *netdev, int new_mtu)
 {
 	struct nicvf *nic = netdev_priv(netdev);
@@ -1318,10 +1319,13 @@ static int nicvf_change_mtu(struct net_device *netdev, int new_mtu)
 	if (new_mtu < NIC_HW_MIN_FRS)
 		return -EINVAL;
 
+	netdev->mtu = new_mtu;
+
+	if (!netif_running(netdev))
+		return 0;
+
 	if (nicvf_update_hw_max_frs(nic, new_mtu))
 		return -EINVAL;
-	netdev->mtu = new_mtu;
-	nic->mtu = new_mtu;
 
 	return 0;
 }
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
index a4fc501..f0e0ca6 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
@@ -1530,6 +1530,9 @@ int nicvf_check_cqe_tx_errs(struct nicvf *nic,
 	case CQ_TX_ERROP_SUBDC_ERR:
 		stats->tx.subdesc_err++;
 		break;
+	case CQ_TX_ERROP_MAX_SIZE_VIOL:
+		stats->tx.max_size_exceeded++;
+		break;
 	case CQ_TX_ERROP_IMM_SIZE_OFLOW:
 		stats->tx.imm_size_oflow++;
 		break;
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h
index 869f338..8f4718e 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.h
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.h
@@ -158,6 +158,7 @@ enum CQ_TX_ERROP_E {
 	CQ_TX_ERROP_DESC_FAULT = 0x10,
 	CQ_TX_ERROP_HDR_CONS_ERR = 0x11,
 	CQ_TX_ERROP_SUBDC_ERR = 0x12,
+	CQ_TX_ERROP_MAX_SIZE_VIOL = 0x13,
 	CQ_TX_ERROP_IMM_SIZE_OFLOW = 0x80,
 	CQ_TX_ERROP_DATA_SEQUENCE_ERR = 0x81,
 	CQ_TX_ERROP_MEM_SEQUENCE_ERR = 0x82,
@@ -177,6 +178,7 @@ struct cmp_queue_stats {
 		u64 desc_fault;
 		u64 hdr_cons_err;
 		u64 subdesc_err;
+		u64 max_size_exceeded;
 		u64 imm_size_oflow;
 		u64 data_seq_err;
 		u64 mem_seq_err;
-- 
2.7.4

^ permalink raw reply related

* [PATCH 1/5] net: thunderx: Introduce BGX_ID_MASK macro to extract bgx_id
From: sunil.kovvuri at gmail.com @ 2016-11-14 10:54 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1479120886-13425-1-git-send-email-sunil.kovvuri@gmail.com>

From: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>

This patch fixes the 'bgx_id' determination on 83xx where there are
4 BGX blocks instead of 2 on other platforms.

Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
Signed-off-by: Sunil Goutham <sgoutham@cavium.com>
---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 4 ++--
 drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
index 8bbaedb..050e21f 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
@@ -1242,8 +1242,8 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	pci_read_config_word(pdev, PCI_DEVICE_ID, &sdevid);
 	if (sdevid != PCI_DEVICE_ID_THUNDER_RGX) {
-		bgx->bgx_id =
-		    (pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM) >> 24) & 1;
+		bgx->bgx_id = (pci_resource_start(pdev,
+			PCI_CFG_REG_BAR_NUM) >> 24) & BGX_ID_MASK;
 		bgx->bgx_id += nic_get_node_id(pdev) * MAX_BGX_PER_NODE;
 		bgx->max_lmac = MAX_LMAC_PER_BGX;
 		bgx_vnic[bgx->bgx_id] = bgx;
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
index d59c71e..01cc7c8 100644
--- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
+++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
@@ -28,6 +28,8 @@
 #define    MAX_DMAC_PER_LMAC			8
 #define    MAX_FRAME_SIZE			9216
 
+#define	   BGX_ID_MASK				0x3
+
 #define    MAX_DMAC_PER_LMAC_TNS_BYPASS_MODE	2
 
 /* Registers */
-- 
2.7.4

^ permalink raw reply related

* [PATCH 0/5] net: thunderx: Miscellaneous fixes
From: sunil.kovvuri at gmail.com @ 2016-11-14 10:54 UTC (permalink / raw)
  To: linux-arm-kernel

From: Sunil Goutham <sgoutham@cavium.com>

This patchset includes fixes for incorrect LMAC credits,
unreliable driver statistics, memory leak upon interface
down e.t.c

Radha Mohan Chintakuntla (1):
  net: thunderx: Introduce BGX_ID_MASK macro to extract bgx_id

Sunil Goutham (4):
  net: thunderx: Program LMAC credits based on MTU
  net: thunderx: Fix configuration of L3/L4 length checking
  net: thunderx: Fix VF driver's interface statistics
  net: thunderx: Fix memory leak and other issues upon interface toggle

 drivers/net/ethernet/cavium/thunder/nic.h          |  64 +++++----
 drivers/net/ethernet/cavium/thunder/nic_main.c     |  37 +++--
 drivers/net/ethernet/cavium/thunder/nic_reg.h      |   1 +
 .../net/ethernet/cavium/thunder/nicvf_ethtool.c    | 105 +++++++-------
 drivers/net/ethernet/cavium/thunder/nicvf_main.c   | 153 +++++++++++----------
 drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 118 +++++++++-------
 drivers/net/ethernet/cavium/thunder/nicvf_queues.h |  24 +---
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c  |   4 +-
 drivers/net/ethernet/cavium/thunder/thunder_bgx.h  |   2 +
 9 files changed, 274 insertions(+), 234 deletions(-)

-- 
2.7.4

^ permalink raw reply

* [PATCH v2 7/7] soc: renesas: Identify SoC and register with the SoC bus
From: Geert Uytterhoeven @ 2016-11-14 10:51 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <25057157.YlGi2v6RrE@wuerfel>

Hi Arnd,

On Thu, Nov 10, 2016 at 12:37 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thursday, November 10, 2016 11:19:20 AM CET Geert Uytterhoeven wrote:
>> On Wed, Nov 9, 2016 at 5:55 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> > On Monday, October 31, 2016 12:30:55 PM CET Geert Uytterhoeven wrote:
>> >> v2:
>> >>   - Drop SoC families and family names; use fixed "Renesas" instead,
>> >
>> > I think I'd rather have seen the family names left in there, but it's
>> > not important, so up to you.
>>
>> They're not useful for matching, as family names may change anytime, and don't
>> always say much about the hardware capabilities.
>> E.g. SH-Mobile -> R-Mobile -> R-Car | RZ/A | RZ/G
>> Some SH-Mobile (even some R-Car) parts are SuperH only, others have ARM and
>> SuperH.
>>
>> At least the SoC part numbers are stable (hmm, sh73a0 == r8a73a0).
>
> I think the marketing names are much more useful for humans looking
> at the sysfs files than the kernel doing matching on, but both use
> cases are important.

OK, I'll re-add the family names for humans reading sysfs.

>> >>   - Use "renesas,prr" and "renesas,cccr" device nodes in DT if
>> >>     available, else fall back to hardcoded addresses for compatibility
>> >>     with existing DTBs,

>> > It does seem wrong to have a device node for a specific register though.
>> > Shouldn't the node be for the block of registers that these are inside
>> > of?
>>
>> On R-Mobile APE6, R-Car Gen2 and Gen3, PRR is a lone register.
>> On R-Car Gen1, it's not even documented (and doesn't exist on all parts).
>
> It just seems odd to have it at address 0xff000044 when all the other
> devices are at page-aligned addresses. Do you mean that accessing
> 0xff000040 or 0xff000048 will result in a bus-level exception for a
> missing register and just 0xff000044 is actually valid for access,
> or is it just the only thing that is documented?

For PRR, all other registers in the page read as all zeroes on all SoCs that
have it. So it really is a lone register.

>> On SH-Mobile/R-Mobile, CCCR may be part of the HPB/APB register block, which
>> we further don't touch at all.
>> On R-Car Gen2, it's not documented, but does exist.
>
> This is where the family names would come in handy ;-) I now have
> no idea which chip(s) you are referring to.

SH/R-Mobile are r8a7740, r8a73a4, sh73a0.
R-Car Gen2 are r8a779[0-4].

> If you know the name of the register block, just put it into DT with
> that name. The driver can trivially add the right offset.

CCCR is different. The amount of registers that read as non-zero depends a lot
on the actual SoC.

HPB/APB is gonna need real DT bindings, which needs some more investigation.
Hence if you don't mind, I'd like to postpone that part, which only affects
the older SoCs. And I'll drop the "renesas,cccr" binding.

For now, having revision detection for R-Car Gen3 (r8a779[56]) using PRR is
most urgent, as several drivers (e.g. HDMI, Ethernet, clocks, pinctrl) are
waiting for this support. So I'd like to have that dependency in v4.10.

>> >>   - Don't register the SoC bus if the chip ID register is missing,
>> >
>> > Why? My objection was to hardcoding the register, not to registering
>> > the device? I think I'd rather see the device registered with an
>> > empty revision string.
>>
>> If there's no chip ID register, there's no reason to use soc_device_match(),
>> as we can always look at a compatible value. All SoCs listed in this driver
>> have a chip ID register.
>
> But you may still have user space tools looking into sysfs, e.g. to
> figure out how to install a kernel that the boot loader can find,
> or which hardware specific distro packages to install.
>
>> if you want me to register the soc_bus for  those SoCs regardless, I want to
>> re-add r7s72100 (RZ/A) and r8a7778 (R-Car M1A), who don't have chip ID
>> registers ;-)
>
> Right. Just don't encode too much knowledge about the SoCs into the
> driver, so we are prepared for adding new ones: We should still look
> for the registers in DT on all chips.

OK, will re-add.

>> >> +static int __init renesas_soc_init(void)
>> >> +{
>> >> +       struct soc_device_attribute *soc_dev_attr;
>> >> +       const struct of_device_id *match;
>> >> +       void __iomem *chipid = NULL;
>> >> +       struct soc_device *soc_dev;
>> >> +       struct device_node *np;
>> >> +       unsigned int product;
>> >> +
>> >> +       np = of_find_matching_node_and_match(NULL, renesas_socs, &match);
>> >> +       if (!np)
>> >> +               return -ENODEV;
>> >> +
>> >> +       of_node_put(np);
>> >> +
>> >> +       /* Try PRR first, then CCCR, then hardcoded fallback */
>> >> +       np = of_find_compatible_node(NULL, NULL, "renesas,prr");
>> >> +       if (!np)
>> >> +               np = of_find_compatible_node(NULL, NULL, "renesas,cccr");
>> >> +       if (np) {
>> >> +               chipid = of_iomap(np, 0);
>> >> +               of_node_put(np);
>> >> +       } else if (match->data) {
>> >> +               chipid = ioremap((uintptr_t)match->data, 4);
>> >> +       }
>> >> +       if (!chipid)
>> >>
>> >
>> > Here, I'd turn the order around and look for the DT nodes of the
>> > devices first. Only if they are not found, look at the compatible
>> > string of the root node. No need to search for a node though,
>> > you know which one it is when you look for a compatible =
>> > "renesas,r8a73a4".
>>
>> "renesas,r8a73a4" is the root node, not the device, so it does not have the
>> "reg" property for reading the chip ID?
>
> I mean replace of_find_matching_node_and_match() with
> of_match_node(renesas_socs, of_root).
>
> It does the same thing, just more efficiently.

OK (didn't know "of_root" was available for public use ;-)

>> There is no SoC part number in the "renesas,prr" and "renesas,cccr" nodes.
>> Hence I always need to look at the root nodes.
>
> Not sure what that would protect you from. Could you have a renesas,cccr

Looks like you forgot to finish your sentence?

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply

* [PATCH v7 04/16] drivers: iommu: make of_iommu_set/get_ops() DT agnostic
From: Lorenzo Pieralisi @ 2016-11-14 10:26 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <33769e3c-265f-6e89-adf9-6d35b1e03579@arm.com>

Hi Robin, Joerg,

On Fri, Nov 11, 2016 at 05:43:39PM +0000, Robin Murphy wrote:
> On 11/11/16 16:27, Joerg Roedel wrote:
> > On Fri, Nov 11, 2016 at 04:17:37PM +0000, Robin Murphy wrote:
> >> In the original of_iommu_configure design, the thought was that an ops
> >> structure could be IOMMU-instance-specific (hence the later-removed
> >> "priv" member), so I suppose right now it is mostly a hangover from
> >> that. However, it's also what we initialise a device's fwspec with, so
> >> becomes important again if we're ever going to get past the limitations
> >> of buses-which-are-not-actually-buses[1].
> > 
> > Yeah, I discussed this with a few others at LPC. My current idea is to
> > tell the iommu-core which hardware-iommus exist in the system and a
> > seperate iommu_ops ptr for each of them. Then every struct device can
> > link to the iommu-instance it is translated by.
> 
> Er, that sounds very much like a description of what we already have in
> 4.9-rc. Every struct device now has an iommu_fwspec which encapsulates
> both an iommu_ops pointer (which can perfectly well be per-instance if
> the IOMMU driver wants) and a place for the IOMMU-private data to
> replace the mess of archdata.iommu and driver-internal globals.
> 
> > We are not there yet, but this will give you the same per-device
> > iommu-ops as implemented here.
> 
> With those two patches I linked to, which make the bulk of the IOMMU
> core code per-device-ops-aware off the bat, I'd say we *are* already
> pretty much there. It's only iommu_domain_alloc() which needs a
> device-based alternative, and the non-of_xlate-based IOMMU drivers to
> either call iommu_fwspec_init() for themselves, or perhaps for x86
> plumbing in DMAR/IVRS equivalents of the IORT parsing to the
> infrastructure provided by this series.

I think it all boils down to how we end up implementing the per-device
iommu_ops look-up/binding, question is what do you want me to do with
this patch, it should be fine to drop it and use dev->bus->iommu_ops
for the look-up but I should know sooner rather than later to make
sure the series get another good round of testing.

Please let me know, thank you very much.

Lorenzo

^ permalink raw reply

* [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode
From: Vladimir Murzin @ 2016-11-14 10:16 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <e1a51dec-cf8c-eb4e-e29a-8845bb8cd1d9@arm.com>

Hi,

On 14/11/16 10:06, Marc Zyngier wrote:
> Hi Vladimir,
> 
> On 07/11/16 09:21, Vladimir Murzin wrote:
>> Hi,
>>
>> This series introduces GICv3 ITS to 32-bit world. Since I'm limited
>> with real world 32-bit platforms which uses ITS it was tested with
>> help of vITS on 64-bit host running 32-bit guest.
>>
>> I used Andrea's its/v8 branch at [1] with following option passed to
>> kvmtool: --aarch32 --irqchip=gicv3-its --force-pci
>>
>> [1] git://www.linux-arm.org/kvmtool.git
>>
>> Changelog:
>>
>>     RFC -> v1
>>         - rebased on 4.9-rc2,  gits_read_typer() has been dropped
>> 	- spilt ITS and vITS in separate patch sets
>> 	
>> Vladimir Murzin (6):
>>   irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility
>>   irqchip/gic-v3-its: Narrow down Entry Size when used as a divider
>>   irqchip/gicv3-its: Specialise flush_dcache operation
>>   irqchip/gicv3-its: Specialise readq and writeq accesses
>>   ARM: gic-v3-its: Add 32bit support to GICv3 ITS
>>   ARM: virt: Select ARM_GIC_V3_ITS
>>
>>  arch/arm/Kconfig                    |    1 +
>>  arch/arm/include/asm/arch_gicv3.h   |   54 +++++++++++++++++++++----
>>  arch/arm64/include/asm/arch_gicv3.h |   17 ++++++++
>>  drivers/irqchip/irq-gic-v3-its.c    |   75 +++++++++++++++++------------------
>>  include/linux/irqchip/arm-gic-v3.h  |    4 +-
>>  5 files changed, 104 insertions(+), 47 deletions(-)
> 
> I've queued all of this in my irq/gic-4.10 branch.
> 

Great!

Thanks
Vladimir

> Thanks,
> 
> 	M.
> 

^ permalink raw reply

* [PATCH 0/8] DMA: s3c64xx: Conversion to the new channel request API
From: Charles Keepax @ 2016-11-14 10:11 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1478791076-19528-1-git-send-email-s.nawrocki@samsung.com>

On Thu, Nov 10, 2016 at 04:17:48PM +0100, Sylwester Nawrocki wrote:
> This patch series aims to convert the s3c64xx platform to use
> the new DMA channel request API, i.e. this is only meaningful 
> for non-dt systems using s3c64xx SoCs.
> 
> Presumably the first 2 or 4 patches in this series could be queued 
> for v4.10-rc1 and the remaining patches could be left for subsequent
> release, to avoid non-trivial conflict with patches already applied 
> in the ASoC tree.
> 
> The whole series can be pulled from git repository:
>  git://linuxtv.org/snawrocki/samsung.git 
>  branch: for-v4.10/dma/pl080-s3c64xx-v2

Tested this series again still looks good to me. The code on that
branch does differ from the code on the list by the following
diff however:

--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -2317,7 +2317,7 @@ static int pl08x_probe(struct amba_device
*adev, const struct amba_id *id)
       } else {
            pl08x->slave.filter.map = pl08x->pd->slave_map;
            pl08x->slave.filter.mapcnt = pl08x->pd->slave_map_len;
-           pl08x->slave.filter.fn = pl08x_filter_id;
+           pl08x->slave.filter.fn = pl08x_filter_fn;
       }

I tested the code from the list, rather than the branch.

Thanks,
Charles

^ permalink raw reply

* [RESEND PATCH v1 0/6] Support GICv3 ITS in 32-bit mode
From: Marc Zyngier @ 2016-11-14 10:06 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1478510482-15471-1-git-send-email-vladimir.murzin@arm.com>

Hi Vladimir,

On 07/11/16 09:21, Vladimir Murzin wrote:
> Hi,
> 
> This series introduces GICv3 ITS to 32-bit world. Since I'm limited
> with real world 32-bit platforms which uses ITS it was tested with
> help of vITS on 64-bit host running 32-bit guest.
> 
> I used Andrea's its/v8 branch at [1] with following option passed to
> kvmtool: --aarch32 --irqchip=gicv3-its --force-pci
> 
> [1] git://www.linux-arm.org/kvmtool.git
> 
> Changelog:
> 
>     RFC -> v1
>         - rebased on 4.9-rc2,  gits_read_typer() has been dropped
> 	- spilt ITS and vITS in separate patch sets
> 	
> Vladimir Murzin (6):
>   irqchip/gic-v3-its: Change unsigned types for AArch32 compatibility
>   irqchip/gic-v3-its: Narrow down Entry Size when used as a divider
>   irqchip/gicv3-its: Specialise flush_dcache operation
>   irqchip/gicv3-its: Specialise readq and writeq accesses
>   ARM: gic-v3-its: Add 32bit support to GICv3 ITS
>   ARM: virt: Select ARM_GIC_V3_ITS
> 
>  arch/arm/Kconfig                    |    1 +
>  arch/arm/include/asm/arch_gicv3.h   |   54 +++++++++++++++++++++----
>  arch/arm64/include/asm/arch_gicv3.h |   17 ++++++++
>  drivers/irqchip/irq-gic-v3-its.c    |   75 +++++++++++++++++------------------
>  include/linux/irqchip/arm-gic-v3.h  |    4 +-
>  5 files changed, 104 insertions(+), 47 deletions(-)

I've queued all of this in my irq/gic-4.10 branch.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply

* [linux-sunxi] Re: [PATCH 3/3] ARM: dts: sunxi: add support for Orange Pi Zero board
From: Hans de Goede @ 2016-11-14 10:00 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <CAGb2v677zQGihbz1o2izM-y5GJ4VDApf6-WDJAk3UyZdsK-vWQ@mail.gmail.com>

HI,

On 14-11-16 10:09, Chen-Yu Tsai wrote:
> On Mon, Nov 14, 2016 at 4:58 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
>> Hi,
>>
>> On Sat, Nov 12, 2016 at 12:46:54AM +0800, Icenowy Zheng wrote:
>>> Orange Pi Zero is a board that came with the new Allwinner H2+ SoC.
>>>
>>> Add a device tree file for it.
>>>
>>> As there's still no mainline-compatible driver for the SDIO WLAN card on
>>> board (a new card by Allwinner), the mmc1 controller is not enabled yet.
>>>
>>> Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
>>> ---
>>>  arch/arm/boot/dts/Makefile                       |   1 +
>>>  arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts | 148 +++++++++++++++++++++++
>>>  2 files changed, 149 insertions(+)
>>>  create mode 100644 arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
>>>
>>> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
>>> index befcd26..9843fb0 100644
>>> --- a/arch/arm/boot/dts/Makefile
>>> +++ b/arch/arm/boot/dts/Makefile
>>> @@ -818,6 +818,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
>>>       sun8i-a33-sinlinx-sina33.dtb \
>>>       sun8i-a83t-allwinner-h8homlet-v2.dtb \
>>>       sun8i-a83t-cubietruck-plus.dtb \
>>> +     sun8i-h2plus-orangepi-zero.dtb \
>>>       sun8i-h3-bananapi-m2-plus.dtb \
>>>       sun8i-h3-nanopi-neo.dtb \
>>>       sun8i-h3-orangepi-2.dtb \
>>> diff --git a/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
>>> new file mode 100644
>>> index 0000000..581f56e
>>> --- /dev/null
>>> +++ b/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
>>> @@ -0,0 +1,148 @@
>>> +/*
>>> + * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
>>> + *
>>> + * Based on sun8i-h3-orangepi-one.dts, which is:
>>> + *   Copyright (C) 2016 Hans de Goede <hdegoede@redhat.com>
>>> + *
>>> + * This file is dual-licensed: you can use it either under the terms
>>> + * of the GPL or the X11 license, at your option. Note that this dual
>>> + * licensing only applies to this file, and not this project as a
>>> + * whole.
>>> + *
>>> + *  a) This file 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 file 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.
>>> + *
>>> + * Or, alternatively,
>>> + *
>>> + *  b) Permission is hereby granted, free of charge, to any person
>>> + *     obtaining a copy of this software and associated documentation
>>> + *     files (the "Software"), to deal in the Software without
>>> + *     restriction, including without limitation the rights to use,
>>> + *     copy, modify, merge, publish, distribute, sublicense, and/or
>>> + *     sell copies of the Software, and to permit persons to whom the
>>> + *     Software is furnished to do so, subject to the following
>>> + *     conditions:
>>> + *
>>> + *     The above copyright notice and this permission notice shall be
>>> + *     included in all copies or substantial portions of the Software.
>>> + *
>>> + *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>>> + *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
>>> + *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
>>> + *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
>>> + *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
>>> + *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>>> + *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
>>> + *     OTHER DEALINGS IN THE SOFTWARE.
>>> + */
>>> +
>>> +/dts-v1/;
>>> +#include "sun8i-h2plus.dtsi"
>>> +#include "sunxi-common-regulators.dtsi"
>>> +
>>> +#include <dt-bindings/gpio/gpio.h>
>>> +#include <dt-bindings/input/input.h>
>>> +#include <dt-bindings/pinctrl/sun4i-a10.h>
>>> +
>>> +/ {
>>> +     model = "Xunlong Orange Pi Zero";
>>> +     compatible = "xunlong,orangepi-zero", "allwinner,sun8i-h2plus",
>>> +                  "allwinner,sun8i-h3";
>>
>> You don't need the H3 compatible here.
>>
>>> +
>>> +     aliases {
>>> +             serial0 = &uart0;
>>> +     };
>>> +
>>> +     chosen {
>>> +             stdout-path = "serial0:115200n8";
>>> +     };
>>> +
>>> +     leds {
>>> +             compatible = "gpio-leds";
>>> +             pinctrl-names = "default";
>>> +             pinctrl-0 = <&leds_opi0>, <&leds_r_opi0>;
>>> +
>>> +             pwr_led {
>>> +                     label = "orangepi:green:pwr";
>>> +                     gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>;
>>> +                     default-state = "on";
>>> +             };
>>> +
>>> +             status_led {
>>> +                     label = "orangepi:red:status";
>>> +                     gpios = <&pio 0 17 GPIO_ACTIVE_HIGH>;
>>> +             };
>>> +     };
>>> +};
>>> +
>>> +&ehci1 {
>>> +     status = "okay";
>>> +};
>>> +
>>> +&mmc0 {
>>> +     pinctrl-names = "default";
>>> +     pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
>>> +     vmmc-supply = <&reg_vcc3v3>;
>>> +     bus-width = <4>;
>>> +     cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
>>> +     cd-inverted;
>>> +     status = "okay";
>>> +};
>>> +
>>> +&ohci1 {
>>> +     status = "okay";
>>> +};
>>> +
>>> +&pio {
>>> +     leds_opi0: led_pins at 0 {
>>> +             allwinner,pins = "PA17";
>>> +             allwinner,function = "gpio_out";
>>> +             allwinner,drive = <SUN4I_PINCTRL_10_MA>;
>>> +             allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
>>> +     };
>>> +};
>>> +
>>> +&r_pio {
>>> +     leds_r_opi0: led_pins at 0 {
>>> +             allwinner,pins = "PL10";
>>> +             allwinner,function = "gpio_out";
>>> +             allwinner,drive = <SUN4I_PINCTRL_10_MA>;
>>> +             allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
>>
>> You can drop the drive and pull properties, and could you use the
>> generic pins and function properties for those nodes?
>
> Icenowy,
> Given that sunxi-next is currently broken for the pinctrl stuff,
> you will need this patch to test, until Linus merges it:
>
>     https://github.com/wens/linux/commit/e8ce92925a6dd1b2b38ed8699e81d0bc9804de20
>
>>
>>> +     };
>>> +};
>>> +
>>> +&uart0 {
>>> +     pinctrl-names = "default";
>>> +     pinctrl-0 = <&uart0_pins_a>;
>>> +     status = "okay";
>>> +};
>>> +
>>> +&uart1 {
>>> +     pinctrl-names = "default";
>>> +     pinctrl-0 = <&uart1_pins>;
>>> +     status = "disabled";
>>> +};
>>> +
>>> +&uart2 {
>>> +     pinctrl-names = "default";
>>> +     pinctrl-0 = <&uart2_pins>;
>>> +     status = "disabled";
>>> +};
>>> +
>>> +&uart3 {
>>> +     pinctrl-names = "default";
>>> +     pinctrl-0 = <&uart3_pins>;
>>> +     status = "disabled";
>>> +};
>>
>> I'm guessing that those UART are exposed on headers?
>>
>>> +
>>> +&usbphy {
>>> +     /* USB VBUS is always on */
>>
>> You can put the always on regulators (I'm guessing reg_vcc5v0 ?) here.
>
> AFAIK the regulator properties are optional the the USB PHY.
> So we probably don't need to add it. Hans (CC-ed) could explain
> his original intent?

I've made the regulators optional exactly for boards like these,
where there is no regulator. Likely the Vbus is simply wired
directly to the 5V DC-in jack. So IMHO adding something like
the fixed reg_vcc5v0 a supply here just makes the dt
harder to read.

Regards,

Hans



>
> Regards
> ChenYu
>
>>
>>> +     status = "okay";
>>> +};
>>
>> Thanks,
>> Maxime
>>
>> --
>> Maxime Ripard, Free Electrons
>> Embedded Linux and Kernel engineering
>> http://free-electrons.com

^ permalink raw reply

* [PATCH v2] staging: vc04_services: rework ioctl code path
From: Dan Carpenter @ 2016-11-14  9:48 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161111061531.23507-1-mzoran@crowfest.net>

On Thu, Nov 10, 2016 at 10:15:31PM -0800, Michael Zoran wrote:
> +static void *
> +vchiq_ioctl_kmalloc(struct vchiq_ioctl_call_context *ctxt, size_t size)
> +{
> +	void *mem;
> +
> +	if (!ctxt->stackmem_used && size < sizeof(ctxt->stackmem)) {
> +		ctxt->stackmem_used = true;
> +		return ctxt->stackmem;
> +	}
> +
> +	mem = kmalloc(size + sizeof(void *), GFP_KERNEL);

This is a potential integer overflow leading to corruption.  I don't
understand why we need this complicated memory management anyway...

> +	if (!mem)
> +		return NULL;
> +
> +	*(void **)mem = ctxt->prev_kmalloc;
> +	ctxt->prev_kmalloc = mem;
> +
> +	return mem + sizeof(void *);
> +}

regards,
dan carpenter

^ permalink raw reply

* [RFC PATCH] ARM64: dts: Add support for Meson GXM
From: Neil Armstrong @ 2016-11-14  9:44 UTC (permalink / raw)
  To: linux-arm-kernel

Following the Amlogic Linux kernel, it seem the only differences
between the GXL and GXM SoCs are the CPU Clusters.

Simply add a meson-gxm dtsi and reproduce the P23x to Q20x boards
dts files since the S905D and S912 SoCs shares the same pinout
and the P23x and Q20x boards are identical.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 Documentation/devicetree/bindings/arm/amlogic.txt  |   6 +
 arch/arm64/boot/dts/amlogic/Makefile               |   2 +
 .../arm64/boot/dts/amlogic/meson-gxm-s912-q200.dts |  76 +++++++++
 .../arm64/boot/dts/amlogic/meson-gxm-s912-q201.dts |  57 +++++++
 .../boot/dts/amlogic/meson-gxm-s912-q20x.dtsi      | 188 +++++++++++++++++++++
 arch/arm64/boot/dts/amlogic/meson-gxm.dtsi         | 114 +++++++++++++
 6 files changed, 443 insertions(+)
 create mode 100644 arch/arm64/boot/dts/amlogic/meson-gxm-s912-q200.dts
 create mode 100644 arch/arm64/boot/dts/amlogic/meson-gxm-s912-q201.dts
 create mode 100644 arch/arm64/boot/dts/amlogic/meson-gxm-s912-q20x.dtsi
 create mode 100644 arch/arm64/boot/dts/amlogic/meson-gxm.dtsi

diff --git a/Documentation/devicetree/bindings/arm/amlogic.txt b/Documentation/devicetree/bindings/arm/amlogic.txt
index fffc179..1144214 100644
--- a/Documentation/devicetree/bindings/arm/amlogic.txt
+++ b/Documentation/devicetree/bindings/arm/amlogic.txt
@@ -25,6 +25,10 @@ Boards with the Amlogic Meson GXL S905D SoC shall have the following properties:
   Required root node property:
     compatible: "amlogic,s905d", "amlogic,meson-gxl";
 
+Boards with the Amlogic Meson GXM S912 SoC shall have the following properties:
+  Required root node property:
+    compatible: "amlogic,s912", "amlogic,meson-gxm";
+
 Board compatible values:
   - "geniatech,atv1200" (Meson6)
   - "minix,neo-x8" (Meson8)
@@ -39,3 +43,5 @@ Board compatible values:
   - "amlogic,p212" (Meson gxl s905x)
   - "amlogic,p230" (Meson gxl s905d)
   - "amlogic,p231" (Meson gxl s905d)
+  - "amlogic,q200" (Meson gxm s912)
+  - "amlogic,q201" (Meson gxm s912)
diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile
index 5a64050..7752a16 100644
--- a/arch/arm64/boot/dts/amlogic/Makefile
+++ b/arch/arm64/boot/dts/amlogic/Makefile
@@ -8,6 +8,8 @@ dtb-$(CONFIG_ARCH_MESON) += meson-gxbb-vega-s95-telos.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-gxl-s905x-p212.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-gxl-s905d-p230.dtb
 dtb-$(CONFIG_ARCH_MESON) += meson-gxl-s905d-p231.dtb
+dtb-$(CONFIG_ARCH_MESON) += meson-gxm-s912-q200.dtb
+dtb-$(CONFIG_ARCH_MESON) += meson-gxm-s912-q201.dtb
 
 always		:= $(dtb-y)
 subdir-y	:= $(dts-dirs)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q200.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q200.dts
new file mode 100644
index 0000000..dfce929
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q200.dts
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016 Endless Computers, Inc.
+ * Author: Carlo Caione <carlo@endlessm.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library 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 library 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "meson-gxm-s912-q20x.dtsi"
+
+/ {
+	compatible = "amlogic,q200", "amlogic,s912", "amlogic,meson-gxm";
+	model = "Amlogic Meson GXM (S912) Q200 Development Board";
+};
+
+/* Q200 has exclusive choice between internal or external PHY */
+&ethmac {
+	pinctrl-0 = <&eth_pins>;
+	pinctrl-names = "default";
+
+	/* Select external PHY by default */
+	phy-handle = <&external_phy>;
+
+	/* External PHY reset is shared with internal PHY Led signals */
+	snps,reset-gpio = <&gpio GPIOZ_14 0>;
+	snps,reset-delays-us = <0 10000 1000000>;
+	snps,reset-active-low;
+
+	/* External PHY is in RGMII */
+	phy-mode = "rgmii";
+};
+
+&external_mdio {
+	external_phy: ethernet-phy at 0 {
+		compatible = "ethernet-phy-id001c.c916", "ethernet-phy-ieee802.3-c22";
+		reg = <0>;
+		max-speed = <1000>;
+	};
+};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q201.dts b/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q201.dts
new file mode 100644
index 0000000..28880c2
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q201.dts
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 Endless Computers, Inc.
+ * Author: Carlo Caione <carlo@endlessm.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library 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 library 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "meson-gxm-s912-q20x.dtsi"
+
+/ {
+	compatible = "amlogic,q201", "amlogic,s912", "amlogic,meson-gxm";
+	model = "Amlogic Meson GXM (S912) Q201 Development Board";
+};
+
+/* Q201 has only internal PHY port */
+&ethmac {
+	phy-mode = "rmii";
+	phy-handle = <&internal_phy>;
+};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q20x.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q20x.dtsi
new file mode 100644
index 0000000..0621910
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm-s912-q20x.dtsi
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2016 Endless Computers, Inc.
+ * Author: Carlo Caione <carlo@endlessm.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library 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 library 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "meson-gxm.dtsi"
+
+/ {
+	aliases {
+		serial0 = &uart_AO;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x0 0x0 0x0 0x80000000>;
+	};
+
+	vddio_boot: regulator-vddio_boot {
+		compatible = "regulator-fixed";
+		regulator-name = "VDDIO_BOOT";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <1800000>;
+	};
+
+	vddao_3v3: regulator-vddao_3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "VDDAO_3V3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+	};
+
+	vcc_3v3: regulator-vcc_3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "VCC_3V3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+	};
+
+	emmc_pwrseq: emmc-pwrseq {
+		compatible = "mmc-pwrseq-emmc";
+		reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
+	};
+
+	wifi32k: wifi32k {
+		compatible = "pwm-clock";
+		#clock-cells = <0>;
+		clock-frequency = <32768>;
+		pwms = <&pwm_ef 0 30518 0>; /* PWM_E at 32.768KHz */
+	};
+
+	sdio_pwrseq: sdio-pwrseq {
+		compatible = "mmc-pwrseq-simple";
+		reset-gpios = <&gpio GPIOX_6 GPIO_ACTIVE_LOW>;
+		clocks = <&wifi32k>;
+		clock-names = "ext_clock";
+	};
+};
+
+/* This UART is brought out to the DB9 connector */
+&uart_AO {
+	status = "okay";
+	pinctrl-0 = <&uart_ao_a_pins>;
+	pinctrl-names = "default";
+};
+
+&ir {
+	status = "okay";
+	pinctrl-0 = <&remote_input_ao_pins>;
+	pinctrl-names = "default";
+};
+
+/* Wireless SDIO Module */
+&sd_emmc_a {
+	status = "okay";
+	pinctrl-0 = <&sdio_pins>;
+	pinctrl-names = "default";
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	bus-width = <4>;
+	cap-sd-highspeed;
+	max-frequency = <100000000>;
+
+	non-removable;
+	disable-wp;
+
+	mmc-pwrseq = <&sdio_pwrseq>;
+
+	vmmc-supply = <&vddao_3v3>;
+	vqmmc-supply = <&vddio_boot>;
+
+	brcmf: bcrmf at 1 {
+		reg = <1>;
+		compatible = "brcm,bcm4329-fmac";
+	};
+};
+
+/* SD card */
+&sd_emmc_b {
+	status = "okay";
+	pinctrl-0 = <&sdcard_pins>;
+	pinctrl-names = "default";
+
+	bus-width = <4>;
+	cap-sd-highspeed;
+	max-frequency = <100000000>;
+	disable-wp;
+
+	cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>;
+	cd-inverted;
+
+	vmmc-supply = <&vddao_3v3>;
+	vqmmc-supply = <&vddio_boot>;
+};
+
+/* eMMC */
+&sd_emmc_c {
+	status = "okay";
+	pinctrl-0 = <&emmc_pins>;
+	pinctrl-names = "default";
+
+	bus-width = <8>;
+	cap-sd-highspeed;
+	cap-mmc-highspeed;
+	max-frequency = <200000000>;
+	non-removable;
+	disable-wp;
+	mmc-ddr-1_8v;
+	mmc-hs200-1_8v;
+
+	mmc-pwrseq = <&emmc_pwrseq>;
+	vmmc-supply = <&vcc_3v3>;
+	vqmmc-supply = <&vddio_boot>;
+};
+
+&pwm_ef {
+	status = "okay";
+	pinctrl-0 = <&pwm_e_pins>;
+	pinctrl-names = "default";
+	clocks = <&clkc CLKID_FCLK_DIV4>;
+	clock-names = "clkin0";
+};
+
+&ethmac {
+	status = "okay";
+};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
new file mode 100644
index 0000000..9a90237
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/meson-gxm.dtsi
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016 Endless Computers, Inc.
+ * Author: Carlo Caione <carlo@endlessm.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library 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 library 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "meson-gxl.dtsi"
+
+/ {
+	compatible = "amlogic,meson-gxm";
+
+	cpus {
+		cpu-map {
+			cluster0 {
+				cpu0 {
+					cpu = <&cpu0>;
+				};
+				cpu1 {
+					cpu = <&cpu1>;
+				};
+				cpu2 {
+					cpu = <&cpu2>;
+				};
+				cpu3 {
+					cpu = <&cpu3>;
+				};
+			};
+
+			cluster1 {
+				cpu0 {
+					cpu = <&cpu4>;
+				};
+				cpu1 {
+					cpu = <&cpu5>;
+				};
+				cpu2 {
+					cpu = <&cpu6>;
+				};
+				cpu3 {
+					cpu = <&cpu7>;
+				};
+			};
+		};
+
+		cpu4: cpu at 100 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x100>;
+			enable-method = "psci";
+			next-level-cache = <&l2>;
+		};
+
+		cpu5: cpu at 101 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x101>;
+			enable-method = "psci";
+			next-level-cache = <&l2>;
+		};
+
+		cpu6: cpu at 102 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x102>;
+			enable-method = "psci";
+			next-level-cache = <&l2>;
+		};
+
+		cpu7: cpu at 103 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a53", "arm,armv8";
+			reg = <0x0 0x103>;
+			enable-method = "psci";
+			next-level-cache = <&l2>;
+		};
+	};
+};
-- 
2.7.0

^ permalink raw reply related

* [PATCH] ARM64: configs: Activate Internal PHY for Meson GXL
From: Neil Armstrong @ 2016-11-14  9:42 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161107104357.24428-1-narmstrong@baylibre.com>

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 arch/arm64/configs/defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index dab2cb0..3890321 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -183,7 +183,10 @@ CONFIG_SMC91X=y
 CONFIG_SMSC911X=y
 CONFIG_STMMAC_ETH=m
 CONFIG_REALTEK_PHY=m
+CONFIG_MESON_GXL_PHY=m
 CONFIG_MICREL_PHY=y
+CONFIG_MDIO_BUS_MUX=y
+CONFIG_MDIO_BUS_MUX_MMIOREG=y
 CONFIG_USB_PEGASUS=m
 CONFIG_USB_RTL8150=m
 CONFIG_USB_RTL8152=m
-- 
1.9.1

^ permalink raw reply related

* [PATCH v3 2/2] phy: rockchip-inno-usb2: correct 480MHz output clock stable time
From: William Wu @ 2016-11-14  9:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1479115631-20137-1-git-send-email-wulf@rock-chips.com>

We found that the system crashed due to 480MHz output clock of
USB2 PHY was unstable after clock had been enabled by gpu module.

Theoretically, 1 millisecond is a critical value for 480MHz
output clock stable time, so we try to change the delay time
to 1.2 millisecond to avoid this issue.

And the commit ed907fb1d7c3 ("phy: rockchip-inno-usb2: correct
clk_ops callback") used prepare callbacks instead of enable
callbacks to support gate a clk if the operation may sleep. So
we can switch from delay to sleep functions.

Signed-off-by: William Wu <wulf@rock-chips.com>
---
Changes in v3:
- fix kbuild test error: too few arguments to function 'usleep_range'

Changes in v2:
- use usleep_range() function instead of mdelay()

 drivers/phy/phy-rockchip-inno-usb2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/phy-rockchip-inno-usb2.c b/drivers/phy/phy-rockchip-inno-usb2.c
index 365e077..0e52b25 100644
--- a/drivers/phy/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/phy-rockchip-inno-usb2.c
@@ -166,7 +166,7 @@ static int rockchip_usb2phy_clk480m_prepare(struct clk_hw *hw)
 			return ret;
 
 		/* waitting for the clk become stable */
-		mdelay(1);
+		usleep_range(1200, 1300);
 	}
 
 	return 0;
-- 
2.0.0

^ permalink raw reply related

* [PATCH v3 1/2] phy: rockchip-inno-usb2: correct clk_ops callback
From: William Wu @ 2016-11-14  9:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1479115631-20137-1-git-send-email-wulf@rock-chips.com>

Since we needs to delay ~1ms to wait for 480MHz output clock
of USB2 PHY to become stable after turn on it, the delay time
is pretty long for something that's supposed to be "atomic"
like a clk_enable(). Consider that clk_enable() will disable
interrupt and that a 1ms interrupt latency is not sensible.

The 480MHz output clock should be handled in prepare callbacks
which support gate a clk if the operation may sleep.

Signed-off-by: William Wu <wulf@rock-chips.com>
---
Changes in v3:
- None

Changes in v2:
- None

 drivers/phy/phy-rockchip-inno-usb2.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/phy/phy-rockchip-inno-usb2.c b/drivers/phy/phy-rockchip-inno-usb2.c
index ac20310..365e077 100644
--- a/drivers/phy/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/phy-rockchip-inno-usb2.c
@@ -153,7 +153,7 @@ static inline bool property_enabled(struct rockchip_usb2phy *rphy,
 	return tmp == reg->enable;
 }
 
-static int rockchip_usb2phy_clk480m_enable(struct clk_hw *hw)
+static int rockchip_usb2phy_clk480m_prepare(struct clk_hw *hw)
 {
 	struct rockchip_usb2phy *rphy =
 		container_of(hw, struct rockchip_usb2phy, clk480m_hw);
@@ -172,7 +172,7 @@ static int rockchip_usb2phy_clk480m_enable(struct clk_hw *hw)
 	return 0;
 }
 
-static void rockchip_usb2phy_clk480m_disable(struct clk_hw *hw)
+static void rockchip_usb2phy_clk480m_unprepare(struct clk_hw *hw)
 {
 	struct rockchip_usb2phy *rphy =
 		container_of(hw, struct rockchip_usb2phy, clk480m_hw);
@@ -181,7 +181,7 @@ static void rockchip_usb2phy_clk480m_disable(struct clk_hw *hw)
 	property_enable(rphy, &rphy->phy_cfg->clkout_ctl, false);
 }
 
-static int rockchip_usb2phy_clk480m_enabled(struct clk_hw *hw)
+static int rockchip_usb2phy_clk480m_prepared(struct clk_hw *hw)
 {
 	struct rockchip_usb2phy *rphy =
 		container_of(hw, struct rockchip_usb2phy, clk480m_hw);
@@ -197,9 +197,9 @@ rockchip_usb2phy_clk480m_recalc_rate(struct clk_hw *hw,
 }
 
 static const struct clk_ops rockchip_usb2phy_clkout_ops = {
-	.enable = rockchip_usb2phy_clk480m_enable,
-	.disable = rockchip_usb2phy_clk480m_disable,
-	.is_enabled = rockchip_usb2phy_clk480m_enabled,
+	.prepare = rockchip_usb2phy_clk480m_prepare,
+	.unprepare = rockchip_usb2phy_clk480m_unprepare,
+	.is_prepared = rockchip_usb2phy_clk480m_prepared,
 	.recalc_rate = rockchip_usb2phy_clk480m_recalc_rate,
 };
 
-- 
2.0.0

^ permalink raw reply related

* [PATCH v3 0/2] phy: rockchip-inno-usb2: correct 480MHz clk_ops callbacks and stable time
From: William Wu @ 2016-11-14  9:27 UTC (permalink / raw)
  To: linux-arm-kernel

This series try to correct the 480MHz output clock of USB2 PHY
clk_ops callback and fix the delay time. It aims to make the
480MHz clock gate more sensible and stable.

Tested on rk3366/rk3399 EVB board.

William Wu (2):
  phy: rockchip-inno-usb2: correct clk_ops callback
  phy: rockchip-inno-usb2: correct 480MHz output clock stable time

 drivers/phy/phy-rockchip-inno-usb2.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.0.0

^ permalink raw reply

* [PATCH] ARM: davinci: enable PM for DT boot
From: Sekhar Nori @ 2016-11-14  9:25 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <m2mvh6km8d.fsf@baylibre.com>

On Friday 11 November 2016 10:06 PM, Kevin Hilman wrote:
> Sekhar Nori <nsekhar@ti.com> writes:
> 
>> On Tuesday 08 November 2016 11:43 PM, Kevin Hilman wrote:
>>> Hi Sekhar,
>>>
>>> Sekhar Nori <nsekhar@ti.com> writes:
>>>
>>>> On Wednesday 26 October 2016 03:17 AM, Kevin Hilman wrote:
>>>>> Currently system PM is only enabled for legacy (non-DT) boot.  Enable
>>>>> for DT boot also.
>>>>>
>>>>> Tested on da850-lcdk using "rtcwake -m mem -s5 -d rtc0".
>>>>>
>>>>> Signed-off-by: Kevin Hilman <khilman@baylibre.com>
>>>>> ---
>>>>>  arch/arm/mach-davinci/da8xx-dt.c | 18 ++++++++++++++++++
>>>>>  1 file changed, 18 insertions(+)
>>>>>
>>>>> diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c
>>>>> index c9f7e9274aa8..a8089fa40d86 100644
>>>>> --- a/arch/arm/mach-davinci/da8xx-dt.c
>>>>> +++ b/arch/arm/mach-davinci/da8xx-dt.c
>>>>> @@ -43,8 +43,26 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {
>>>>>  
>>>>>  #ifdef CONFIG_ARCH_DAVINCI_DA850
>>>>>  
>>>>> +static struct davinci_pm_config da850_pm_pdata = {
>>>>> +	.sleepcount = 128,
>>>>> +};
>>>>> +
>>>>> +static struct platform_device da850_pm_device = {
>>>>> +	.name           = "pm-davinci",
>>>>> +	.dev = {
>>>>> +		.platform_data	= &da850_pm_pdata,
>>>>> +	},
>>>>> +	.id             = -1,
>>>>> +};
>>>>> +
>>>>>  static void __init da850_init_machine(void)
>>>>>  {
>>>>> +	int ret;
>>>>> +
>>>>> +	ret = da850_register_pm(&da850_pm_device);
>>>>
>>>> I am not sure if it makes sense to keep the "pm device" around anymore.
>>>> I think for both DT and non-DT boot, we can get rid of the fake PM
>>>> device and combine da850_register_pm() and davinci_pm_probe() into a
>>>> single davinci_init_suspend() function which can then be called both for
>>>> DT and non-DT boot.
>>>
>>> Looking closer at this, where do you propose the pdata comes from for
>>> the non-DT boot?
>>>
>>> It seems to me that we can't currently remove the pdata dependency
>>> without breaking the non-DT platforms, so the approach proposed here is
>>> the least invasive.
>>
>> There is a single value of sleep count that is used today (128). So I
>> was thinking we can hardcode that in pm.c. We are not going to add more
>> board files anyway so there is no risk here.
>>
>> For future, if a different sleepcount value is needed, it will need to
>> be a new DT property.
> 
> Right, but getting rid of the pdata is more than just hard-coding the
> sleep count. There are a bunch of other fields in the pdata, which are
> filled out to some standard defaults in da850.c.  Are you proposing to
> hard-code those in pm.c also?

Yeah. When I wrote the code for pm.c, I wrote it hoping that it can be
used on other davinci devices too. But since then, no other DaVinci
device has gained PM support. DM365 could support PM, but its not
supported even on TI's internal releases.

Even if in future PM does get supported on DM365, platform data will not
be used for sure. And besides, the sequence in sleep.S has only ever
been tested on DA850 and pretty sure will need some tweaks for running
on DM365.

> 
> An intermediate step might be to start by removing the
> platform_device/pdata from the board files, but keep it in da850.c for
> now.  Then, a follow-up cleanup could be done to either move all of that
> into pm.c, or use DT.

I think keeping it in pm.c is fine. We could have called pm.c da850-pm.c
but thats not really required I guess since thats the only device in
mach-davinci which supports suspend-to-RAM anyway.

Thanks,
Sekhar

^ permalink raw reply

* PM regression with LED changes in next-20161109
From: Jacek Anaszewski @ 2016-11-14  9:12 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <9b476f85-d45e-deb6-335d-fc56f6d90350@redhat.com>

Hi,

On 11/13/2016 02:52 PM, Hans de Goede wrote:
> Hi,
>
> On 13-11-16 12:44, Jacek Anaszewski wrote:
>> Hi,
>>
>> On 11/12/2016 10:14 PM, Hans de Goede wrote:
>
> <snip>
>
>>>>> So I would like to propose creating a new read-write
>>>>> user_brightness file.
>>>>>
>>>>> The write behavior would be 100% identical to the brightness
>>>>> file (in code terms it will call the same store function).
>>>>>
>>>>> The the read behavior otoh will be different: it will shows
>>>>> the last brightness as set by the user, this would show the
>>>>> read behavior we really want of brightness: show the real
>>>>> brightness when not blinking / triggers are active and show
>>>>> the brightness used when on when blinking / triggers are active.
>>>>>
>>>>> We could then add poll support on this new user_brightness
>>>>> file, thus avoiding the problem with the extra cpu-load on
>>>>> notifications on blinking / triggers.
>>>>
>>>> I agree that user_brightness allows to solve the issues you raised
>>>> about inconsistent write and read brightness' semantics
>>>> (which is not that painful IMHO).
>>>>
>>>> Reporting non-user brightness changes on user_brightness file
>>>> doesn't sound reasonable though.
>>>
>>> The changes I'm interested in are user brightness changes they
>>> are just not done through sysfs, but through a hardwired hotkey,
>>> they are however very much done by the user.
>>
>> Ah, so this file name would be misleading especially taking into account
>> the context in which "user" is used in kernel, which predominantly
>> means "userspace", e.g. copy_to_user(), copy_from_user().
>>
>>>> Also, how would we read the
>>>> brightness set by the firmware? We'd have to read brightness
>>>> file, so still two files would have to be opened which is
>>>> a second drawback of this approach.
>>>
>>> No, look carefully at the definition of the read behavior
>>> I plan to put in the ABI doc:
>>
>> OK, "user" was what confused me. So in this case changes made
>> by the firmware even if in a result of user activity
>> (pressing hardware key) obviously cannot be treated similarly
>> to the changes made from the userspace context.
>
> In the end both result on the brightness of the device
> changing, so any userspace process interested in monitoring
> the brightness will want to know about both type of changes.
>
>> Unless you're able to give references to the kernel code which
>> contradict my judgement.
>
> AFAIK the audio code will signal volume changes done by
> hardwired buttons the same way as audio changes done
> by userspace calling into the kernel. This also makes
> sense because in the end, what is interesting for a
> mixer app, is that the volume changed, and what the
> new volume is.

OK, so it is indeed similar to your LED use case. Nonetheless
in case of LED controllers it is also possible that hardware
adjusts LED brightness in case of low battery voltage.

If a device is able e.g. to generate an interrupt to notify this
kind of event, then we would like also to be able to notify the client
about that. It wouldn't be user generated brightness change though.

>>> "Reading this file will return the actual led brightness
>>> when not blinking and no triggers are active; reading this
>>> file will return the brightness used when the led is on
>>> when blinking or triggers are active."
>>
>> This is unnecessarily entangled. Blinking means timer trigger
>> is active.
>
> Ok.
>
>>> So for e.g. the backlit keyboard case reading this single
>>> file will return the actual brightness of the backlight,
>>> since this does not involve blinking or triggers.
>>>
>>> Basically the idea is that the user_brightness file
>>> will have the semantics which IMHO the brightness file
>>> itself should have had from the beginning, but which
>>> we can't change now due to ABI reasons.
>>
>> And in fact introducing user_brightness file would indeed
>> fix that shortcoming. However without providing notifications
>> of hw brightness changes on it.
>
> See above, I believe such a file should report any
> changes in brightness, except those caused by triggers,
> so it would report hw brightness changes.
>
> Anyways if you're not interested in fixing the
> shortcomings of the current read behavior on the
> brightness file (I'm fine with that, I can live
> with the shortcomings) I suggest that we simply go
> with v2 of my poll() patch.

v2 entails power consumption related issues.

Generally I think that we could add the file you proposed,
however it would be good to devise a name which will cover
also the cases when brightness is changed by firmware without
user interaction.

>>>> Having no difference in this area between the two approaches
>>>> I'm still in favour of the read-only file for notifying
>>>> brightness changes procured by hardware.
>>>
>>> That brings back the needing 2 fds problem; and does
>>> not solve userspace not being able to reliably read
>>> the led on brightness when blinking or using triggers.
>>>
>>> And this also has the issue that one is doing poll() on
>>> one fd to detect changes on another fd,
>>
>> It is not necessarily true. We can treat the polling on
>> hw_brightness_change file as a means to detect brightness
>> changes procured by hardware and we can read that brightness
>> by executing read on this same fd. It could return -ENODATA
>> if no such an event has occurred so far.
>
> That would still require 2 fds as userspace also wants to
> be able to set the keyboard backlight, but allowing read()
> on the hw_brightness_change file at least fixes the weirdness
> where userspace gets woken from poll() without being able to
> read. So if you insist on going the hw_brightness_change file
> route, then I can live with that (and upower will simply
> need to open 2 fds, that is doable).
>
> But, BUT, I would greatly prefer to just go for v4 of my
> patch, which fixes the only real problem we've seen with
> my patch as original merged without adding a new, somewhat
> convoluted sysfs attribute.

Hmm, v4 still calls led_notify_brightness_change(led_cdev)
from both __led_set_brightness() and __led_set_brightness_blocking().

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply

* [PATCH 3/3] ARM: dts: sunxi: add support for Orange Pi Zero board
From: Chen-Yu Tsai @ 2016-11-14  9:09 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161114085839.qzu7ebeghoqlqygn@lukather>

On Mon, Nov 14, 2016 at 4:58 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> On Sat, Nov 12, 2016 at 12:46:54AM +0800, Icenowy Zheng wrote:
>> Orange Pi Zero is a board that came with the new Allwinner H2+ SoC.
>>
>> Add a device tree file for it.
>>
>> As there's still no mainline-compatible driver for the SDIO WLAN card on
>> board (a new card by Allwinner), the mmc1 controller is not enabled yet.
>>
>> Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
>> ---
>>  arch/arm/boot/dts/Makefile                       |   1 +
>>  arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts | 148 +++++++++++++++++++++++
>>  2 files changed, 149 insertions(+)
>>  create mode 100644 arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
>>
>> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
>> index befcd26..9843fb0 100644
>> --- a/arch/arm/boot/dts/Makefile
>> +++ b/arch/arm/boot/dts/Makefile
>> @@ -818,6 +818,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
>>       sun8i-a33-sinlinx-sina33.dtb \
>>       sun8i-a83t-allwinner-h8homlet-v2.dtb \
>>       sun8i-a83t-cubietruck-plus.dtb \
>> +     sun8i-h2plus-orangepi-zero.dtb \
>>       sun8i-h3-bananapi-m2-plus.dtb \
>>       sun8i-h3-nanopi-neo.dtb \
>>       sun8i-h3-orangepi-2.dtb \
>> diff --git a/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
>> new file mode 100644
>> index 0000000..581f56e
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
>> @@ -0,0 +1,148 @@
>> +/*
>> + * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
>> + *
>> + * Based on sun8i-h3-orangepi-one.dts, which is:
>> + *   Copyright (C) 2016 Hans de Goede <hdegoede@redhat.com>
>> + *
>> + * This file is dual-licensed: you can use it either under the terms
>> + * of the GPL or the X11 license, at your option. Note that this dual
>> + * licensing only applies to this file, and not this project as a
>> + * whole.
>> + *
>> + *  a) This file 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 file 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.
>> + *
>> + * Or, alternatively,
>> + *
>> + *  b) Permission is hereby granted, free of charge, to any person
>> + *     obtaining a copy of this software and associated documentation
>> + *     files (the "Software"), to deal in the Software without
>> + *     restriction, including without limitation the rights to use,
>> + *     copy, modify, merge, publish, distribute, sublicense, and/or
>> + *     sell copies of the Software, and to permit persons to whom the
>> + *     Software is furnished to do so, subject to the following
>> + *     conditions:
>> + *
>> + *     The above copyright notice and this permission notice shall be
>> + *     included in all copies or substantial portions of the Software.
>> + *
>> + *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> + *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
>> + *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
>> + *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
>> + *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
>> + *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
>> + *     OTHER DEALINGS IN THE SOFTWARE.
>> + */
>> +
>> +/dts-v1/;
>> +#include "sun8i-h2plus.dtsi"
>> +#include "sunxi-common-regulators.dtsi"
>> +
>> +#include <dt-bindings/gpio/gpio.h>
>> +#include <dt-bindings/input/input.h>
>> +#include <dt-bindings/pinctrl/sun4i-a10.h>
>> +
>> +/ {
>> +     model = "Xunlong Orange Pi Zero";
>> +     compatible = "xunlong,orangepi-zero", "allwinner,sun8i-h2plus",
>> +                  "allwinner,sun8i-h3";
>
> You don't need the H3 compatible here.
>
>> +
>> +     aliases {
>> +             serial0 = &uart0;
>> +     };
>> +
>> +     chosen {
>> +             stdout-path = "serial0:115200n8";
>> +     };
>> +
>> +     leds {
>> +             compatible = "gpio-leds";
>> +             pinctrl-names = "default";
>> +             pinctrl-0 = <&leds_opi0>, <&leds_r_opi0>;
>> +
>> +             pwr_led {
>> +                     label = "orangepi:green:pwr";
>> +                     gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>;
>> +                     default-state = "on";
>> +             };
>> +
>> +             status_led {
>> +                     label = "orangepi:red:status";
>> +                     gpios = <&pio 0 17 GPIO_ACTIVE_HIGH>;
>> +             };
>> +     };
>> +};
>> +
>> +&ehci1 {
>> +     status = "okay";
>> +};
>> +
>> +&mmc0 {
>> +     pinctrl-names = "default";
>> +     pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
>> +     vmmc-supply = <&reg_vcc3v3>;
>> +     bus-width = <4>;
>> +     cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
>> +     cd-inverted;
>> +     status = "okay";
>> +};
>> +
>> +&ohci1 {
>> +     status = "okay";
>> +};
>> +
>> +&pio {
>> +     leds_opi0: led_pins at 0 {
>> +             allwinner,pins = "PA17";
>> +             allwinner,function = "gpio_out";
>> +             allwinner,drive = <SUN4I_PINCTRL_10_MA>;
>> +             allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
>> +     };
>> +};
>> +
>> +&r_pio {
>> +     leds_r_opi0: led_pins at 0 {
>> +             allwinner,pins = "PL10";
>> +             allwinner,function = "gpio_out";
>> +             allwinner,drive = <SUN4I_PINCTRL_10_MA>;
>> +             allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
>
> You can drop the drive and pull properties, and could you use the
> generic pins and function properties for those nodes?

Icenowy,
Given that sunxi-next is currently broken for the pinctrl stuff,
you will need this patch to test, until Linus merges it:

    https://github.com/wens/linux/commit/e8ce92925a6dd1b2b38ed8699e81d0bc9804de20

>
>> +     };
>> +};
>> +
>> +&uart0 {
>> +     pinctrl-names = "default";
>> +     pinctrl-0 = <&uart0_pins_a>;
>> +     status = "okay";
>> +};
>> +
>> +&uart1 {
>> +     pinctrl-names = "default";
>> +     pinctrl-0 = <&uart1_pins>;
>> +     status = "disabled";
>> +};
>> +
>> +&uart2 {
>> +     pinctrl-names = "default";
>> +     pinctrl-0 = <&uart2_pins>;
>> +     status = "disabled";
>> +};
>> +
>> +&uart3 {
>> +     pinctrl-names = "default";
>> +     pinctrl-0 = <&uart3_pins>;
>> +     status = "disabled";
>> +};
>
> I'm guessing that those UART are exposed on headers?
>
>> +
>> +&usbphy {
>> +     /* USB VBUS is always on */
>
> You can put the always on regulators (I'm guessing reg_vcc5v0 ?) here.

AFAIK the regulator properties are optional the the USB PHY.
So we probably don't need to add it. Hans (CC-ed) could explain
his original intent?

Regards
ChenYu

>
>> +     status = "okay";
>> +};
>
> Thanks,
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com

^ permalink raw reply

* [PATCH 1/3] soc: sunxi: make sunxi_sram explicitly non-modular
From: Maxime Ripard @ 2016-11-14  8:59 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161113190302.18099-2-paul.gortmaker@windriver.com>

On Sun, Nov 13, 2016 at 02:03:00PM -0500, Paul Gortmaker wrote:
> The Kconfig currently controlling compilation of this code is:
> 
> drivers/soc/sunxi/Kconfig:config SUNXI_SRAM
> drivers/soc/sunxi/Kconfig:      bool
> 
> ...meaning that it currently is not being built as a module by anyone.
> 
> Lets remove the modular code that is essentially orphaned, so that
> when reading the driver there is no doubt it is builtin-only.
> 
> Since module_platform_driver() uses the same init level priority as
> builtin_platform_driver() the init ordering remains unchanged with
> this commit.
> 
> Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
> 
> We also delete the MODULE_LICENSE tag etc. since all that information
> is already contained at the top of the file in the comments.
> 
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> Cc: linux-arm-kernel at lists.infradead.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161114/be8785c8/attachment.sig>

^ permalink raw reply

* [PATCH 3/3] ARM: dts: sunxi: add support for Orange Pi Zero board
From: Maxime Ripard @ 2016-11-14  8:58 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161111164654.15273-3-icenowy@aosc.xyz>

Hi,

On Sat, Nov 12, 2016 at 12:46:54AM +0800, Icenowy Zheng wrote:
> Orange Pi Zero is a board that came with the new Allwinner H2+ SoC.
> 
> Add a device tree file for it.
> 
> As there's still no mainline-compatible driver for the SDIO WLAN card on
> board (a new card by Allwinner), the mmc1 controller is not enabled yet.
> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
> ---
>  arch/arm/boot/dts/Makefile                       |   1 +
>  arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts | 148 +++++++++++++++++++++++
>  2 files changed, 149 insertions(+)
>  create mode 100644 arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
> 
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index befcd26..9843fb0 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -818,6 +818,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
>  	sun8i-a33-sinlinx-sina33.dtb \
>  	sun8i-a83t-allwinner-h8homlet-v2.dtb \
>  	sun8i-a83t-cubietruck-plus.dtb \
> +	sun8i-h2plus-orangepi-zero.dtb \
>  	sun8i-h3-bananapi-m2-plus.dtb \
>  	sun8i-h3-nanopi-neo.dtb \
>  	sun8i-h3-orangepi-2.dtb \
> diff --git a/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts b/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
> new file mode 100644
> index 0000000..581f56e
> --- /dev/null
> +++ b/arch/arm/boot/dts/sun8i-h2plus-orangepi-zero.dts
> @@ -0,0 +1,148 @@
> +/*
> + * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
> + *
> + * Based on sun8i-h3-orangepi-one.dts, which is:
> + *   Copyright (C) 2016 Hans de Goede <hdegoede@redhat.com>
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file 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 file 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.
> + *
> + * Or, alternatively,
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + *     obtaining a copy of this software and associated documentation
> + *     files (the "Software"), to deal in the Software without
> + *     restriction, including without limitation the rights to use,
> + *     copy, modify, merge, publish, distribute, sublicense, and/or
> + *     sell copies of the Software, and to permit persons to whom the
> + *     Software is furnished to do so, subject to the following
> + *     conditions:
> + *
> + *     The above copyright notice and this permission notice shall be
> + *     included in all copies or substantial portions of the Software.
> + *
> + *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> + *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> + *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> + *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + *     OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +/dts-v1/;
> +#include "sun8i-h2plus.dtsi"
> +#include "sunxi-common-regulators.dtsi"
> +
> +#include <dt-bindings/gpio/gpio.h>
> +#include <dt-bindings/input/input.h>
> +#include <dt-bindings/pinctrl/sun4i-a10.h>
> +
> +/ {
> +	model = "Xunlong Orange Pi Zero";
> +	compatible = "xunlong,orangepi-zero", "allwinner,sun8i-h2plus",
> +		     "allwinner,sun8i-h3";

You don't need the H3 compatible here.

> +
> +	aliases {
> +		serial0 = &uart0;
> +	};
> +
> +	chosen {
> +		stdout-path = "serial0:115200n8";
> +	};
> +
> +	leds {
> +		compatible = "gpio-leds";
> +		pinctrl-names = "default";
> +		pinctrl-0 = <&leds_opi0>, <&leds_r_opi0>;
> +
> +		pwr_led {
> +			label = "orangepi:green:pwr";
> +			gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>;
> +			default-state = "on";
> +		};
> +
> +		status_led {
> +			label = "orangepi:red:status";
> +			gpios = <&pio 0 17 GPIO_ACTIVE_HIGH>;
> +		};
> +	};
> +};
> +
> +&ehci1 {
> +	status = "okay";
> +};
> +
> +&mmc0 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
> +	vmmc-supply = <&reg_vcc3v3>;
> +	bus-width = <4>;
> +	cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
> +	cd-inverted;
> +	status = "okay";
> +};
> +
> +&ohci1 {
> +	status = "okay";
> +};
> +
> +&pio {
> +	leds_opi0: led_pins at 0 {
> +		allwinner,pins = "PA17";
> +		allwinner,function = "gpio_out";
> +		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
> +		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
> +	};
> +};
> +
> +&r_pio {
> +	leds_r_opi0: led_pins at 0 {
> +		allwinner,pins = "PL10";
> +		allwinner,function = "gpio_out";
> +		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
> +		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;

You can drop the drive and pull properties, and could you use the
generic pins and function properties for those nodes?

> +	};
> +};
> +
> +&uart0 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart0_pins_a>;
> +	status = "okay";
> +};
> +
> +&uart1 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart1_pins>;
> +	status = "disabled";
> +};
> +
> +&uart2 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart2_pins>;
> +	status = "disabled";
> +};
> +
> +&uart3 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&uart3_pins>;
> +	status = "disabled";
> +};

I'm guessing that those UART are exposed on headers?

> +
> +&usbphy {
> +	/* USB VBUS is always on */

You can put the always on regulators (I'm guessing reg_vcc5v0 ?) here.

> +	status = "okay";
> +};

Thanks,
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161114/7d01c738/attachment.sig>

^ permalink raw reply

* [PATCH 2/3] ARM: dts: sunxi: add Allwinner H2+ dtsi
From: Maxime Ripard @ 2016-11-14  8:55 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161111164654.15273-2-icenowy@aosc.xyz>

On Sat, Nov 12, 2016 at 12:46:53AM +0800, Icenowy Zheng wrote:
> Allwinner H2+ is a SoC so similar with H3 that H3 drivers and memory map
> is known to work well on H2+, with both BSP kernel/firmware or the
> mainline ones.
> 
> So add a dtsi file which only include the H3 dtsi only, so we can add
> H2+-specified nodes in the dtsi file when we find any software
> difference between H2+ and H3.
> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>

I don't think we need that patch at all. You can do it just like we
did for the R8 and R16, just include the H3 DTSI in your board. We'll
create it if we need it at some point.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161114/1a597c68/attachment-0001.sig>

^ permalink raw reply

* [PATCH 1/3] ARM: sunxi: add support for H2+ SoC
From: Maxime Ripard @ 2016-11-14  8:54 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161111164654.15273-1-icenowy@aosc.xyz>

Hi,

On Sat, Nov 12, 2016 at 12:46:52AM +0800, Icenowy Zheng wrote:
> Allwinner H2+ is a quad-core Cortex-A7 SoC.
> 
> It is very like H3, that they share the same SoC ID (0x1680), and H3
> memory maps as well as drivers works well on the SoC.
> 
> Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
> ---
>  Documentation/arm/sunxi/README                  | 4 ++++
>  Documentation/devicetree/bindings/arm/sunxi.txt | 1 +
>  arch/arm/mach-sunxi/sunxi.c                     | 1 +
>  3 files changed, 6 insertions(+)
> 
> diff --git a/Documentation/arm/sunxi/README b/Documentation/arm/sunxi/README
> index cd02433..1fe4d99c 100644
> --- a/Documentation/arm/sunxi/README
> +++ b/Documentation/arm/sunxi/README
> @@ -63,6 +63,10 @@ SunXi family
>          + User Manual
>            http://dl.linux-sunxi.org/A33/A33%20user%20manual%20release%201.1.pdf
>  
> +      - Allwinner H2+ (sun8i)
> +        + No document available now, but is known to be working properly with
> +          H3 drivers and memory map.
> +
>        - Allwinner H3 (sun8i)
>          + Datasheet
>            http://dl.linux-sunxi.org/H3/Allwinner_H3_Datasheet_V1.0.pdf
> diff --git a/Documentation/devicetree/bindings/arm/sunxi.txt b/Documentation/devicetree/bindings/arm/sunxi.txt
> index 3975d0a..0c0f277 100644
> --- a/Documentation/devicetree/bindings/arm/sunxi.txt
> +++ b/Documentation/devicetree/bindings/arm/sunxi.txt
> @@ -13,5 +13,6 @@ using one of the following compatible strings:
>    allwinner,sun8i-a33
>    allwinner,sun8i-a83t
>    allwinner,sun8i-h3
> +  allwinner,sun8i-h2plus

That's a nitpick, but I'd prefer to have sun8i-h2-plus.

Thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20161114/085010ba/attachment.sig>

^ permalink raw reply

* [PATCH 03/16] ARM: berlin: use generic API for enabling SCU
From: Jisheng Zhang @ 2016-11-14  8:51 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1479099731-28108-4-git-send-email-pankaj.dubey@samsung.com>

Hi Pankaj,

On Mon, 14 Nov 2016 10:31:58 +0530 Pankaj Dubey wrote:

> Now as we have of_scu_enable which takes care of mapping
> scu base from DT, lets use it.
> 
> CC: Jisheng Zhang <jszhang@marvell.com>
> CC: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> ---
>  arch/arm/mach-berlin/platsmp.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/mach-berlin/platsmp.c b/arch/arm/mach-berlin/platsmp.c
> index 93f9068..25a6ca5 100644
> --- a/arch/arm/mach-berlin/platsmp.c
> +++ b/arch/arm/mach-berlin/platsmp.c
> @@ -60,26 +60,21 @@ static int berlin_boot_secondary(unsigned int cpu, struct task_struct *idle)
>  static void __init berlin_smp_prepare_cpus(unsigned int max_cpus)
>  {
>  	struct device_node *np;
> -	void __iomem *scu_base;
>  	void __iomem *vectors_base;
>  
> -	np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
> -	scu_base = of_iomap(np, 0);
> -	of_node_put(np);
> -	if (!scu_base)
> -		return;
> -
>  	np = of_find_compatible_node(NULL, NULL, "marvell,berlin-cpu-ctrl");
>  	cpu_ctrl = of_iomap(np, 0);
>  	of_node_put(np);
>  	if (!cpu_ctrl)
> -		goto unmap_scu;
> +		return;
>  
>  	vectors_base = ioremap(CONFIG_VECTORS_BASE, SZ_32K);
>  	if (!vectors_base)
> -		goto unmap_scu;
> +		return;
> +
> +	if (of_scu_enable())

In err code path, we need to unmap vectors_base before return

> +		return;
>  
> -	scu_enable(scu_base);
>  	flush_cache_all();
>  
>  	/*
> @@ -95,8 +90,6 @@ static void __init berlin_smp_prepare_cpus(unsigned int max_cpus)
>  	writel(virt_to_phys(secondary_startup), vectors_base + SW_RESET_ADDR);
>  
>  	iounmap(vectors_base);
> -unmap_scu:
> -	iounmap(scu_base);
>  }
>  
>  #ifdef CONFIG_HOTPLUG_CPU

^ permalink raw reply

* [PATCH 01/16] ARM: scu: Provide support for parsing SCU device node to enable SCU
From: Jisheng Zhang @ 2016-11-14  8:47 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161114145459.63c23391@xhacker>

Hi Pankaj,

On Mon, 14 Nov 2016 14:54:59 +0800 Jisheng Zhang wrote:

> On Mon, 14 Nov 2016 14:12:51 +0800 Jisheng Zhang wrote:
> 
> > Hi Pankaj,
> > 
> > On Mon, 14 Nov 2016 10:31:56 +0530 Pankaj Dubey wrote:
> >   
> > > Many platforms are duplicating code for enabling SCU, lets add
> > > common code to enable SCU by parsing SCU device node so the duplication
> > > in each platform can be avoided.
> > > 
> > > CC: Krzysztof Kozlowski <krzk@kernel.org>
> > > CC: Jisheng Zhang <jszhang@marvell.com>
> > > CC: Russell King <linux@armlinux.org.uk>
> > > CC: Dinh Nguyen <dinguyen@opensource.altera.com>
> > > CC: Patrice Chotard <patrice.chotard@st.com>
> > > CC: Linus Walleij <linus.walleij@linaro.org>
> > > CC: Liviu Dudau <liviu.dudau@arm.com>
> > > CC: Ray Jui <rjui@broadcom.com>
> > > CC: Stephen Warren <swarren@wwwdotorg.org>
> > > CC: Heiko Stuebner <heiko@sntech.de>
> > > CC: Shawn Guo <shawnguo@kernel.org>
> > > CC: Michal Simek <michal.simek@xilinx.com>
> > > CC: Wei Xu <xuwei5@hisilicon.com>
> > > CC: Andrew Lunn <andrew@lunn.ch>
> > > CC: Jun Nie <jun.nie@linaro.org> 
> > > Suggested-by: Arnd Bergmann <arnd@arndb.de>
> > > Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com>
> > > ---
> > >  arch/arm/include/asm/smp_scu.h |  4 +++
> > >  arch/arm/kernel/smp_scu.c      | 56 ++++++++++++++++++++++++++++++++++++++++++
> > >  2 files changed, 60 insertions(+)
> > > 
> > > diff --git a/arch/arm/include/asm/smp_scu.h b/arch/arm/include/asm/smp_scu.h
> > > index bfe163c..fdeec07 100644
> > > --- a/arch/arm/include/asm/smp_scu.h
> > > +++ b/arch/arm/include/asm/smp_scu.h
> > > @@ -39,8 +39,12 @@ static inline int scu_power_mode(void __iomem *scu_base, unsigned int mode)
> > >  
> > >  #if defined(CONFIG_SMP) && defined(CONFIG_HAVE_ARM_SCU)
> > >  void scu_enable(void __iomem *scu_base);
> > > +void __iomem *of_scu_get_base(void);
> > > +int of_scu_enable(void);
> > >  #else
> > >  static inline void scu_enable(void __iomem *scu_base) {}
> > > +static inline void __iomem *of_scu_get_base(void) {return NULL; }
> > > +static inline int of_scu_enable(void) {return 0; }
> > >  #endif
> > >  
> > >  #endif
> > > diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c
> > > index 72f9241..d0ac3ed 100644
> > > --- a/arch/arm/kernel/smp_scu.c
> > > +++ b/arch/arm/kernel/smp_scu.c
> > > @@ -10,6 +10,7 @@
> > >   */
> > >  #include <linux/init.h>
> > >  #include <linux/io.h>
> > > +#include <linux/of_address.h>
> > >  
> > >  #include <asm/smp_plat.h>
> > >  #include <asm/smp_scu.h>
> > > @@ -70,6 +71,61 @@ void scu_enable(void __iomem *scu_base)
> > >  	 */
> > >  	flush_cache_all();
> > >  }
> > > +
> > > +static const struct of_device_id scu_match[] = {
> > > +	{ .compatible = "arm,cortex-a9-scu", },
> > > +	{ .compatible = "arm,cortex-a5-scu", },
> > > +	{ }
> > > +};
> > > +
> > > +/*
> > > + * Helper API to get SCU base address
> > > + * In case platform DT do not have SCU node, or iomap fails
> > > + * this call will fallback and will try to map via call to
> > > + * scu_a9_get_base.
> > > + * This will return ownership of scu_base to the caller
> > > + */
> > > +void __iomem *of_scu_get_base(void)
> > > +{
> > > +	unsigned long base = 0;
> > > +	struct device_node *np;
> > > +	void __iomem *scu_base;
> > > +
> > > +	np = of_find_matching_node(NULL, scu_match);    
> > 
> > could we check np before calling of_iomap()?
> >   
> > > +	scu_base = of_iomap(np, 0);
> > > +	of_node_put(np);
> > > +	if (!scu_base) {
> > > +		pr_err("%s failed to map scu_base via DT\n", __func__);    
> > 
> > For non-ca5, non-ca9 based SoCs, we'll see this error msg. We understand
> > what does it mean, but it may confuse normal users. In current version,
> > berlin doesn't complain like this for non-ca9 SoCs  
> 
> oops, I just realized that the non-ca9 berlin arm SoC version isn't upstreamed.
> Below is the draft version I planed. Basically speaking, the code tries to
> find "arm,cortex-a9-scu" node from DT, if can't, we think we don't need to
> worry about SCU. Is there any elegant solution for my situation?

I just realized that (another realized :D) we uses PSCI enable method for
non-ca9 base SoCs, so "marvell,berlin-smp" enable method is only for the SoCs
which have CA9 compatible SCU. Sorry for the noise, your patch looks good to me.

^ permalink raw reply

* [PATCH 01/16] ARM: scu: Provide support for parsing SCU device node to enable SCU
From: pankaj.dubey @ 2016-11-14  8:40 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20161114141251.7ea86e7a@xhacker>


Hi Jisheng,

On Monday 14 November 2016 11:42 AM, Jisheng Zhang wrote:
> Hi Pankaj,
> 
> On Mon, 14 Nov 2016 10:31:56 +0530 Pankaj Dubey wrote:

<snip>

>> +
>> +	np = of_find_matching_node(NULL, scu_match);
> 
> could we check np before calling of_iomap()?
> 

of_iomap takes care of that, and will return NULL if np is NULL.

So additional check of np is not required here.

>> +	scu_base = of_iomap(np, 0);
>> +	of_node_put(np);
>> +	if (!scu_base) {
>> +		pr_err("%s failed to map scu_base via DT\n", __func__);
> 
> For non-ca5, non-ca9 based SoCs, we'll see this error msg. We understand
> what does it mean, but it may confuse normal users. In current version,
> berlin doesn't complain like this for non-ca9 SoCs
> 

OK, let me see other reviewer's comment on this. Then we will decide if
this error message is required or can be omitted.


Thanks,
Pankaj Dubey

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox