QUICC Engine support on ARM and ARM64
Subsystems (10)
v4 cover QUICC Engine support on ARM and ARM64
There have been several attempts in the past few years to allow building the QUICC engine drivers for platforms other than PPC. This is yet another attempt.
v3 can be found here: https://lore.kernel.org/lkml/[email protected]/
v4 adds a some patches to fix (ab)use of IS_ERR_VALUE which fails when sizeof(u32) != sizeof(long), i.e. on 64-bit platforms. Freescale drivers are some of the last holdouts using that macro (outside of arch/ and core mm code), so I decided trying to simply get rid of it instead of papering over it by using a temporary long to store the result in. Doing that I stumbled on some other things that should be fixed. These are the new patches 34-45.
Patch 35 from v3 (which added a PPC32 dependency to FSL_UCC_HDLC) is gone from this version, so that that driver can indeed now be built for arm and arm64.
1-5 are about replacing in_be32 etc. in the core QE code (drivers/soc/fsl/qe).
6-8 handle miscellaneous other ppcisms.
9-21 deal with qe_ic: Simplifying the driver significantly by removing unused code, and removing the platform-specific initialization from arch/powerpc/.
22-25 deal with raw access to devicetree properties in native endianness.
26-33 makes drivers/tty/serial/ucc_uart.c (CONFIG_SERIAL_QE) ready to build on arm.
34-45 deal with IS_ERR_VALUE() and some other things found while digging around that part of the code.
46 adds a PPC32 dependency to UCC_GETH - it has some of the same issues that have been fixed in the ucc_uart and ucc_hdlc cases. Nobody has requested that I allow that driver to be built for arm{,64}, so instead of growing this series even bigger, I kept that addition. It's trivial to remove if somebody cares enough to fix the build errors/warnings and actually has a platform to test the result on.
Finally patch 47 lifts the PPC32 restriction from QUICC_ENGINE. At the request of Li Yang, it doesn't remove the PPC32 dependency but instead changes it to PPC32 || ARM || ARM64 (or COMPILE_TEST), i.e. listing the platforms that may have a QE.
The series has been built and booted on both an mpc8309-based platform (ppc) as well as an ls1021a-based platform (arm). The core QE code is exercised on both, while I could only test the ucc_uart on arm, since the uarts are not wired up on our mpc8309 board. Qiang Zhao reports that the ucc_hdlc driver does indeed work on a ls1043ardb (arm64) board, I hope he'll formally add a Tested-by: to the relevant patches since I don't have any arm64 board with QE.
Rasmus Villemoes (47):
soc: fsl: qe: remove space-before-tab
soc: fsl: qe: drop volatile qualifier of struct qe_ic::regs
soc: fsl: qe: rename qe_(clr/set/clrset)bit* helpers
soc: fsl: qe: introduce qe_io{read,write}* wrappers
soc: fsl: qe: avoid ppc-specific io accessors
soc: fsl: qe: replace spin_event_timeout by readx_poll_timeout_atomic
soc: fsl: qe: qe.c: guard use of pvr_version_is() with CONFIG_PPC32
soc: fsl: qe: drop unneeded #includes
soc: fsl: qe: drop assign-only high_active in qe_ic_init
soc: fsl: qe: remove pointless sysfs registration in qe_ic.c
soc: fsl: qe: use qe_ic_cascade_{low,high}_mpic also on 83xx
soc: fsl: qe: move calls of qe_ic_init out of arch/powerpc/ powerpc/83xx: remove mpc83xx_ipic_and_qe_init_IRQ powerpc/85xx: remove mostly pointless mpc85xx_qe_init()
soc: fsl: qe: move qe_ic_cascade_* functions to qe_ic.c
soc: fsl: qe: rename qe_ic_cascade_low_mpic -> qe_ic_cascade_low
soc: fsl: qe: remove unused qe_ic_set_* functions
soc: fsl: qe: don't use NO_IRQ in qe_ic.c
soc: fsl: qe: make qe_ic_get_{low,high}_irq static
soc: fsl: qe: simplify qe_ic_init()
soc: fsl: qe: merge qe_ic.h headers into qe_ic.c
soc: fsl: qe: qe.c: use of_property_read_* helpers
soc: fsl: qe: qe_io.c: don't open-code of_parse_phandle()
soc: fsl: qe: qe_io.c: access device tree property using be32_to_cpu
soc: fsl: qe: qe_io.c: use of_property_read_u32() in par_io_init()
soc: fsl: move cpm.h from powerpc/include/asm to include/soc/fsl soc/fsl/qe/qe.h: update include path for cpm.h
serial: ucc_uart: explicitly include soc/fsl/cpm.h
serial: ucc_uart: replace ppc-specific IO accessors
serial: ucc_uart: factor out soft_uart initialization
serial: ucc_uart: stub out soft_uart_init for !CONFIG_PPC32
serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
serial: ucc_uart: access __be32 field using be32_to_cpu
soc: fsl: qe: change return type of cpm_muram_alloc() to s32
soc: fsl: qe: make cpm_muram_free() return void
soc: fsl: qe: make cpm_muram_free() ignore a negative offset
soc: fsl: qe: drop broken lazy call of cpm_muram_init()
soc: fsl: qe: refactor cpm_muram_alloc_common to prevent BUG on error
path
soc: fsl: qe: avoid IS_ERR_VALUE in ucc_slow.c
soc: fsl: qe: drop use of IS_ERR_VALUE in qe_sdma_init()
soc: fsl: qe: drop pointless check in qe_sdma_init()
soc: fsl: qe: avoid IS_ERR_VALUE in ucc_fast.c net/wan/fsl_ucc_hdlc: avoid use of IS_ERR_VALUE() net/wan/fsl_ucc_hdlc: fix reading of __be16 registers net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
net: ethernet: freescale: make UCC_GETH explicitly depend on PPC32
soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE
arch/powerpc/include/asm/cpm.h | 172 +------- arch/powerpc/platforms/83xx/km83xx.c | 3 +- arch/powerpc/platforms/83xx/misc.c | 23 -- arch/powerpc/platforms/83xx/mpc832x_mds.c | 3 +- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 3 +- arch/powerpc/platforms/83xx/mpc836x_mds.c | 3 +- arch/powerpc/platforms/83xx/mpc836x_rdk.c | 3 +- arch/powerpc/platforms/83xx/mpc83xx.h | 7 - arch/powerpc/platforms/85xx/common.c | 23 -- arch/powerpc/platforms/85xx/corenet_generic.c | 12 - arch/powerpc/platforms/85xx/mpc85xx.h | 2 - arch/powerpc/platforms/85xx/mpc85xx_mds.c | 28 -- arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 18 - arch/powerpc/platforms/85xx/twr_p102x.c | 16 - drivers/net/ethernet/freescale/Kconfig | 2 +- drivers/net/wan/fsl_ucc_hdlc.c | 23 +- drivers/net/wan/fsl_ucc_hdlc.h | 2 +- drivers/soc/fsl/qe/Kconfig | 3 +- drivers/soc/fsl/qe/gpio.c | 34 +- drivers/soc/fsl/qe/qe.c | 104 ++--- drivers/soc/fsl/qe/qe_common.c | 50 +-- drivers/soc/fsl/qe/qe_ic.c | 285 ++++++------- drivers/soc/fsl/qe/qe_ic.h | 99 ----- drivers/soc/fsl/qe/qe_io.c | 70 ++-- drivers/soc/fsl/qe/qe_tdm.c | 8 +- drivers/soc/fsl/qe/ucc.c | 26 +- drivers/soc/fsl/qe/ucc_fast.c | 86 ++-- drivers/soc/fsl/qe/ucc_slow.c | 60 ++- drivers/soc/fsl/qe/usb.c | 2 +- drivers/tty/serial/ucc_uart.c | 383 +++++++++--------- include/soc/fsl/cpm.h | 171 ++++++++ include/soc/fsl/qe/qe.h | 59 ++- include/soc/fsl/qe/qe_ic.h | 135 ------ include/soc/fsl/qe/ucc_fast.h | 4 +- include/soc/fsl/qe/ucc_slow.h | 6 +- 35 files changed, 770 insertions(+), 1158 deletions(-) delete mode 100644 drivers/soc/fsl/qe/qe_ic.h create mode 100644 include/soc/fsl/cpm.h delete mode 100644 include/soc/fsl/qe/qe_ic.h
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 1/47 soc: fsl: qe: remove space-before-tab
--- drivers/soc/fsl/qe/qe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/fsl/qe/qe.c +2 -2
@@ -378,8 +378,8 @@ static int qe_sdma_init(void) }out_be32 (&sdma->sdebcr, (u32 ) sdma_buf_offset &QE_SDEBCR_BA_MASK ); -out_be32 (&sdma->sdmr, (QE_SDMR_GLB_1_MSK | - (0x1 <<QE_SDMR_CEN_SHIFT ))); +out_be32 (&sdma->sdmr, (QE_SDMR_GLB_1_MSK | + (0x1 <<QE_SDMR_CEN_SHIFT )));return 0 ; }
Signature · 1 line
2.23.0
PATCH v4 2/47 soc: fsl: qe: drop volatile qualifier of struct qe_ic::regs
In reply to Rasmus VillemoesThe actual io accessors (e.g. in_be32) implicitly add a volatile qualifier to their address argument. Remove volatile from the struct definition and the qe_ic_(read/write) helpers, in preparation for switching from the ppc-specific io accessors to generic ones.
--- drivers/soc/fsl/qe/qe_ic.c | 4 ++-- drivers/soc/fsl/qe/qe_ic.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +2 -2
@@ -171,12 +171,12 @@ static struct qe_ic_info qe_ic_info[] = { }, }; -static inline u32 qe_ic_read (volatile __be32 __iomem * base,unsigned int reg) +static inline u32 qe_ic_read (__be32 __iomem *base,unsigned int reg) {return in_be32 (base + (reg >>2 )); } -static inline void qe_ic_write (volatile __be32 __iomem * base,unsigned int reg, +static inline void qe_ic_write (__be32 __iomem *base,unsigned int reg,u32 value) {out_be32 (base + (reg >>2 ), value);
drivers/soc/fsl/qe/qe_ic.h +1 -1
@@ -72,7 +72,7 @@struct qe_ic {/* Control registers offset */ -volatile u32 __iomem *regs; +u32 __iomem *regs;/* The remapper for this QEIC */ struct irq_domain *irqhost;
Signature · 1 line
2.23.0
PATCH v4 3/47 soc: fsl: qe: rename qe_(clr/set/clrset)bit* helpers
In reply to Rasmus VillemoesMake it clear that these operate on big-endian registers (i.e. use the iowrite*be primitives) before we introduce more uses of them and allow the QE drivers to be built for platforms other than ppc32.
--- drivers/net/wan/fsl_ucc_hdlc.c | 4 ++-- drivers/soc/fsl/qe/ucc.c | 10 +++++----- include/soc/fsl/qe/qe.h | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/net/wan/fsl_ucc_hdlc.c +2 -2
@@ -623,8 +623,8 @@ static int ucc_hdlc_poll(struct napi_struct *napi, int budget)if (howmany < budget) {napi_complete_done (napi, howmany); -qe_setbits32 (priv->uccf->p_uccm, - (UCCE_HDLC_RX_EVENTS |UCCE_HDLC_TX_EVENTS ) <<16 ); +qe_setbits_be32 (priv->uccf->p_uccm, + (UCCE_HDLC_RX_EVENTS |UCCE_HDLC_TX_EVENTS ) <<16 ); }return howmany;
drivers/soc/fsl/qe/ucc.c +5 -5
@@ -540,8 +540,8 @@ int ucc_set_tdm_rxtx_clk(u32 tdm_num, enum qe_clock clock, cmxs1cr = (tdm_num <4 ) ? &qe_mux_reg->cmxsi1cr_l : &qe_mux_reg->cmxsi1cr_h; -qe_clrsetbits32 (cmxs1cr,QE_CMXUCR_TX_CLK_SRC_MASK << shift, - clock_bits << shift); +qe_clrsetbits_be32 (cmxs1cr,QE_CMXUCR_TX_CLK_SRC_MASK << shift, + clock_bits << shift);return 0 ; }
@@ -650,9 +650,9 @@ int ucc_set_tdm_rxtx_sync(u32 tdm_num, enum qe_clock clock, shift =ucc_get_tdm_sync_shift (mode, tdm_num); -qe_clrsetbits32 (&qe_mux_reg->cmxsi1syr, -QE_CMXUCR_TX_CLK_SRC_MASK << shift, - source << shift); +qe_clrsetbits_be32 (&qe_mux_reg->cmxsi1syr, +QE_CMXUCR_TX_CLK_SRC_MASK << shift, + source << shift);return 0 ; }
include/soc/fsl/qe/qe.h +9 -9
@@ -241,20 +241,20 @@ static inline int qe_alive_during_sleep(void)#define qe_muram_offset cpm_muram_offset#define qe_muram_dma cpm_muram_dma -#define qe_setbits32 (_addr, _v) iowrite32be(ioread32be(_addr) | (_v), (_addr)) -#define qe_clrbits32 (_addr, _v) iowrite32be(ioread32be(_addr) & ~(_v), (_addr)) +#define qe_setbits_be32 (_addr, _v) iowrite32be(ioread32be(_addr) | (_v), (_addr)) +#define qe_clrbits_be32 (_addr, _v) iowrite32be(ioread32be(_addr) & ~(_v), (_addr)) -#define qe_setbits16 (_addr, _v) iowrite16be(ioread16be(_addr) | (_v), (_addr)) -#define qe_clrbits16 (_addr, _v) iowrite16be(ioread16be(_addr) & ~(_v), (_addr)) +#define qe_setbits_be16 (_addr, _v) iowrite16be(ioread16be(_addr) | (_v), (_addr)) +#define qe_clrbits_be16 (_addr, _v) iowrite16be(ioread16be(_addr) & ~(_v), (_addr)) -#define qe_setbits8 (_addr, _v) iowrite8(ioread8(_addr) | (_v), (_addr)) -#define qe_clrbits8 (_addr, _v) iowrite8(ioread8(_addr) & ~(_v), (_addr)) +#define qe_setbits_8 (_addr, _v) iowrite8(ioread8(_addr) | (_v), (_addr)) +#define qe_clrbits_8 (_addr, _v) iowrite8(ioread8(_addr) & ~(_v), (_addr)) -#define qe_clrsetbits32 (addr, clear, set) \ +#define qe_clrsetbits_be32 (addr, clear, set) \ iowrite32be((ioread32be(addr) & ~(clear)) | (set), (addr)) -#define qe_clrsetbits16 (addr, clear, set) \ +#define qe_clrsetbits_be16 (addr, clear, set) \ iowrite16be((ioread16be(addr) & ~(clear)) | (set), (addr)) -#define qe_clrsetbits8 (addr, clear, set) \ +#define qe_clrsetbits_8 (addr, clear, set) \ iowrite8((ioread8(addr) & ~(clear)) | (set), (addr))/* Structure that defines QE firmware binary files.
Signature · 1 line
2.23.0
PATCH v4 4/47 soc: fsl: qe: introduce qe_io{read,write}* wrappers
In reply to Rasmus VillemoesThe QUICC engine drivers use the powerpc-specific out_be32() etc. In order to allow those drivers to build for other architectures, those must be replaced by iowrite32be(). However, on powerpc, out_be32() is a simple inline function while iowrite32be() is out-of-line. So in order not to introduce a performance regression on powerpc when making the drivers work on other architectures, introduce qe_io* helpers.
Also define the qe_{clr,set,clrset}bits* helpers in terms of these new macros.
--- include/soc/fsl/qe/qe.h | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-)
include/soc/fsl/qe/qe.h +25 -9
@@ -241,21 +241,37 @@ static inline int qe_alive_during_sleep(void)#define qe_muram_offset cpm_muram_offset#define qe_muram_dma cpm_muram_dma -#define qe_setbits_be32 (_addr, _v) iowrite32be(ioread32be(_addr) | (_v), (_addr)) -#define qe_clrbits_be32 (_addr, _v) iowrite32be(ioread32be(_addr) & ~(_v), (_addr)) +#ifdef CONFIG_PPC32 +#define qe_iowrite8 (val, addr) out_8(addr, val) +#define qe_iowrite16be (val, addr) out_be16(addr, val) +#define qe_iowrite32be (val, addr) out_be32(addr, val) +#define qe_ioread8 (addr) in_8(addr) +#define qe_ioread16be (addr) in_be16(addr) +#define qe_ioread32be (addr) in_be32(addr) +#else +#define qe_iowrite8 (val, addr) iowrite8(val, addr) +#define qe_iowrite16be (val, addr) iowrite16be(val, addr) +#define qe_iowrite32be (val, addr) iowrite32be(val, addr) +#define qe_ioread8 (addr) ioread8(addr) +#define qe_ioread16be (addr) ioread16be(addr) +#define qe_ioread32be (addr) ioread32be(addr) +#endif + +#define qe_setbits_be32 (_addr, _v) qe_iowrite32be(qe_ioread32be(_addr) | (_v), (_addr)) +#define qe_clrbits_be32 (_addr, _v) qe_iowrite32be(qe_ioread32be(_addr) & ~(_v), (_addr)) -#define qe_setbits_be16 (_addr, _v) iowrite16be(ioread16be(_addr) | (_v), (_addr)) -#define qe_clrbits_be16 (_addr, _v) iowrite16be(ioread16be(_addr) & ~(_v), (_addr)) +#define qe_setbits_be16 (_addr, _v) qe_iowrite16be(qe_ioread16be(_addr) | (_v), (_addr)) +#define qe_clrbits_be16 (_addr, _v) qe_iowrite16be(qe_ioread16be(_addr) & ~(_v), (_addr)) -#define qe_setbits_8 (_addr, _v) iowrite8(ioread8(_addr) | (_v), (_addr)) -#define qe_clrbits_8 (_addr, _v) iowrite8(ioread8(_addr) & ~(_v), (_addr)) +#define qe_setbits_8 (_addr, _v) qe_iowrite8(qe_ioread8(_addr) | (_v), (_addr)) +#define qe_clrbits_8 (_addr, _v) qe_iowrite8(qe_ioread8(_addr) & ~(_v), (_addr))#define qe_clrsetbits_be32 (addr, clear, set) \ - iowrite32be((ioread32be(addr) & ~(clear)) | (set), (addr)) + qe_iowrite32be((qe_ioread32be(addr) & ~(clear)) | (set), (addr))#define qe_clrsetbits_be16 (addr, clear, set) \ - iowrite16be((ioread16be(addr) & ~(clear)) | (set), (addr)) + qe_iowrite16be((qe_ioread16be(addr) & ~(clear)) | (set), (addr))#define qe_clrsetbits_8 (addr, clear, set) \ - iowrite8((ioread8(addr) & ~(clear)) | (set), (addr)) + qe_iowrite8((qe_ioread8(addr) & ~(clear)) | (set), (addr))/* Structure that defines QE firmware binary files. *
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Timur Tabi
maintainerRe: [PATCH v4 04/47] soc: fsl: qe: introduce qe_io{read,write}* wrappers
Quoted 7 lines · Rasmus Villemoes
The QUICC engine drivers use the powerpc-specific
out_be32()etc. In order to allow those drivers to build for other architectures, those must be replaced byiowrite32be(). However, on powerpc,out_be32()is a simple inline function whileiowrite32be()is out-of-line. So in order not to introduce a performance regression on powerpc when making the drivers work on other architectures, introduce qe_io* helpers.
Isn't it also true that iowrite32be() assumes a little-endian platform and always does a byte swap?
Re: [PATCH v4 04/47] soc: fsl: qe: introduce qe_io{read,write}* wrappers
Quoted 10 lines · Timur Tabi
Quoted 7 lines · Rasmus Villemoes
The QUICC engine drivers use the powerpc-specific
out_be32()etc. In order to allow those drivers to build for other architectures, those must be replaced byiowrite32be(). However, on powerpc,out_be32()is a simple inline function whileiowrite32be()is out-of-line. So in order not to introduce a performance regression on powerpc when making the drivers work on other architectures, introduce qe_io* helpers.
Quoted 3 lines
Isn't it also true that
iowrite32be()assumes a little-endian platform and always does a byte swap?
No. You're probably thinking of the implementation in lib/iomap.c where one has
#define mmio_read32be(addr) swab32(readl(addr)) unsigned int ioread32be(void __iomem *addr)
{
IO_COND(addr, return pio_read32be(port), return
mmio_read32be(addr));
return 0xffffffff;
}#define mmio_write32be(val,port) writel(swab32(val),port) void iowrite32be(u32 val, void __iomem *addr)
{
IO_COND(addr, pio_write32be(val,port), mmio_write32be(val, addr));
}but that's because readl and writel by definition work on little-endian registers. I.e., on a BE platform, the readl and writel implementation must themselves contain a swab, so the above would end up doing two swabs on a BE platform.
(On PPC, there's a separate definition of mmio_read32be, namely writel_be, which in turn does a out_be32, so on PPC that doesn't actually end up doing two swabs).
So ioread32be etc. have well-defined semantics: access a big-endian register and return the result in native endianness.
Timur Tabi
maintainerRe: [PATCH v4 04/47] soc: fsl: qe: introduce qe_io{read,write}* wrappers
Quoted 4 lines · Rasmus Villemoes
but that's because readl and writel by definition work on little-endian registers. I.e., on a BE platform, the readl and writel implementation must themselves contain a swab, so the above would end up doing two swabs on a BE platform.
Do you know whether the compiler optimizes-out the double swab?
Quoted 6 lines
(On PPC, there's a separate definition of
mmio_read32be, namelywritel_be, which in turn does aout_be32, so on PPC that doesn't actually end up doing two swabs).So ioread32be etc. have well-defined semantics: access a big-endian register and return the result in native endianness.
It seems weird that there aren't any cross-arch lightweight endian-specific I/O accessors.
Re: [PATCH v4 04/47] soc: fsl: qe: introduce qe_io{read,write}* wrappers
Quoted 8 lines · Timur Tabi
Quoted 4 lines · Rasmus Villemoes
but that's because readl and writel by definition work on little-endian registers. I.e., on a BE platform, the readl and writel implementation must themselves contain a swab, so the above would end up doing two swabs on a BE platform.
Do you know whether the compiler optimizes-out the double swab?
Depends. It's almost impossible to figure out how swab32() is defined, so how much visibility gcc has into how it works is hard to say. But a further complication is that the arch may not have, say (simplifying somewhat)
#define readl(x) swab32(*(volatile u32*)x)
but instead have readl implemented as inline asm which includes the byteswap. PPC being a case in point, where the readl is in_le32 which is done with a lwbrx instruction, and certainly gcc couldn't in any way change a swab32(asm("lwbrx")) into asm("lwz"). But ppc defines its own mmio_read32be, so that's not an issue.
Quoted 9 lines
Quoted 6 lines
(On PPC, there's a separate definition of
mmio_read32be, namelywritel_be, which in turn does aout_be32, so on PPC that doesn't actually end up doing two swabs).So ioread32be etc. have well-defined semantics: access a big-endian register and return the result in native endianness.
It seems weird that there aren't any cross-arch lightweight endian-specific I/O accessors.
Agreed, but I'm really not prepared for trying to go down that rabbit hole again.
Rasmus
PATCH v4 5/47 soc: fsl: qe: avoid ppc-specific io accessors
In reply to Rasmus VillemoesIn preparation for allowing to build QE support for architectures other than PPC, replace the ppc-specific io accessors by the qe_io* macros. Done via
$ spatch --sp-file io.cocci --in-place drivers/soc/fsl/qe/
where io.cocci is
@@
expression addr, val;
@@
- out_be32(addr, val)
+ qe_iowrite32be(val, addr)
@@
expression addr;
@@
- in_be32(addr)
+ qe_ioread32be(addr)
@@
expression addr, val;
@@
- out_be16(addr, val)
+ qe_iowrite16be(val, addr)
@@
expression addr;
@@
- in_be16(addr)
+ qe_ioread16be(addr)
@@
expression addr, val;
@@
- out_8(addr, val)
+ qe_iowrite8(val, addr)
@@
expression addr;
@@
- in_8(addr)
+ qe_ioread8(addr)
@@
expression addr, clr, set;
@@
- clrsetbits_be32(addr, clr, set)
+ qe_clrsetbits_be32(addr, clr, set)
@@
expression addr, clr, set;
@@
- clrsetbits_be16(addr, clr, set)
+ qe_clrsetbits_be16(addr, clr, set)
@@
expression addr, clr, set;
@@
- clrsetbits_8(addr, clr, set)
+ qe_clrsetbits_8(addr, clr, set)
@@
expression addr, set;
@@
- setbits32(addr, set)
+ qe_setbits_be32(addr, set)
@@
expression addr, set;
@@
- setbits16(addr, set)
+ qe_setbits_be16(addr, set)
@@
expression addr, set;
@@
- setbits8(addr, set)
+ qe_setbits_8(addr, set)
@@
expression addr, clr;
@@
- clrbits32(addr, clr)
+ qe_clrbits_be32(addr, clr)
@@
expression addr, clr;
@@
- clrbits16(addr, clr)
+ qe_clrbits_be16(addr, clr)
@@
expression addr, clr;
@@
- clrbits8(addr, clr)
+ qe_clrbits_8(addr, clr)
--- drivers/soc/fsl/qe/gpio.c | 34 +++++++++-------- drivers/soc/fsl/qe/qe.c | 38 ++++++++++--------- drivers/soc/fsl/qe/qe_ic.c | 5 ++- drivers/soc/fsl/qe/qe_io.c | 40 +++++++++----------- drivers/soc/fsl/qe/qe_tdm.c | 8 ++-- drivers/soc/fsl/qe/ucc.c | 16 ++++---- drivers/soc/fsl/qe/ucc_fast.c | 71 ++++++++++++++++++----------------- drivers/soc/fsl/qe/ucc_slow.c | 38 +++++++++---------- drivers/soc/fsl/qe/usb.c | 2 +- 9 files changed, 129 insertions(+), 123 deletions(-)
drivers/soc/fsl/qe/gpio.c +19 -15
@@ -41,13 +41,13 @@ static void qe_gpio_save_regs(struct of_mm_gpio_chip *mm_gc) container_of(mm_gc, struct qe_gpio_chip, mm_gc);struct qe_pio_regs __iomem *regs = mm_gc->regs; - qe_gc->cpdata =in_be32 (®s->cpdata); + qe_gc->cpdata =qe_ioread32be (®s->cpdata); qe_gc->saved_regs.cpdata = qe_gc->cpdata; - qe_gc->saved_regs.cpdir1 =in_be32 (®s->cpdir1); - qe_gc->saved_regs.cpdir2 =in_be32 (®s->cpdir2); - qe_gc->saved_regs.cppar1 =in_be32 (®s->cppar1); - qe_gc->saved_regs.cppar2 =in_be32 (®s->cppar2); - qe_gc->saved_regs.cpodr =in_be32 (®s->cpodr); + qe_gc->saved_regs.cpdir1 =qe_ioread32be (®s->cpdir1); + qe_gc->saved_regs.cpdir2 =qe_ioread32be (®s->cpdir2); + qe_gc->saved_regs.cppar1 =qe_ioread32be (®s->cppar1); + qe_gc->saved_regs.cppar2 =qe_ioread32be (®s->cppar2); + qe_gc->saved_regs.cpodr =qe_ioread32be (®s->cpodr); }static int qe_gpio_get (struct gpio_chip *gc,unsigned int gpio)
@@ -56,7 +56,7 @@ static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio)struct qe_pio_regs __iomem *regs = mm_gc->regs;u32 pin_mask =1 << (QE_PIO_PINS -1 - gpio); -return !!(in_be32 (®s->cpdata) & pin_mask); +return !!(qe_ioread32be (®s->cpdata) & pin_mask); }static void qe_gpio_set (struct gpio_chip *gc,unsigned int gpio,int val)
@@ -74,7 +74,7 @@ static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)else qe_gc->cpdata &= ~pin_mask; -out_be32 (®s->cpdata, qe_gc->cpdata); +qe_iowrite32be (qe_gc->cpdata, ®s->cpdata);spin_unlock_irqrestore (&qe_gc->lock, flags); }
@@ -101,7 +101,7 @@ static void qe_gpio_set_multiple(struct gpio_chip *gc, } } -out_be32 (®s->cpdata, qe_gc->cpdata); +qe_iowrite32be (qe_gc->cpdata, ®s->cpdata);spin_unlock_irqrestore (&qe_gc->lock, flags); }
@@ -255,11 +255,15 @@ void qe_pin_set_dedicated(struct qe_pin *qe_pin)spin_lock_irqsave (&qe_gc->lock, flags);if (second_reg) { -clrsetbits_be32 (®s->cpdir2, mask2, sregs->cpdir2 & mask2); -clrsetbits_be32 (®s->cppar2, mask2, sregs->cppar2 & mask2); +qe_clrsetbits_be32 (®s->cpdir2, mask2, + sregs->cpdir2 & mask2); +qe_clrsetbits_be32 (®s->cppar2, mask2, + sregs->cppar2 & mask2); }else { -clrsetbits_be32 (®s->cpdir1, mask2, sregs->cpdir1 & mask2); -clrsetbits_be32 (®s->cppar1, mask2, sregs->cppar1 & mask2); +qe_clrsetbits_be32 (®s->cpdir1, mask2, + sregs->cpdir1 & mask2); +qe_clrsetbits_be32 (®s->cppar1, mask2, + sregs->cppar1 & mask2); }if (sregs->cpdata & mask1)
@@ -267,8 +271,8 @@ void qe_pin_set_dedicated(struct qe_pin *qe_pin)else qe_gc->cpdata &= ~mask1; -out_be32 (®s->cpdata, qe_gc->cpdata); -clrsetbits_be32 (®s->cpodr, mask1, sregs->cpodr & mask1); +qe_iowrite32be (qe_gc->cpdata, ®s->cpdata); +qe_clrsetbits_be32 (®s->cpodr, mask1, sregs->cpodr & mask1);spin_unlock_irqrestore (&qe_gc->lock, flags); }
drivers/soc/fsl/qe/qe.c +20 -18
@@ -112,7 +112,7 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)spin_lock_irqsave (&qe_lock, flags);if (cmd ==QE_RESET ) { -out_be32 (&qe_immr->cp.cecr, (u32) (cmd |QE_CR_FLG )); +qe_iowrite32be ((u32)(cmd |QE_CR_FLG ), &qe_immr->cp.cecr); }else {if (cmd ==QE_ASSIGN_PAGE ) {/* Here device is the SNUM, not sub-block */
@@ -129,15 +129,14 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input) mcn_shift =QE_CR_MCN_NORMAL_SHIFT ; } -out_be32 (&qe_immr->cp.cecdr, cmd_input); -out_be32 (&qe_immr->cp.cecr, - (cmd |QE_CR_FLG | ((u32 ) device << dev_shift) | (u32 ) - mcn_protocol << mcn_shift)); +qe_iowrite32be (cmd_input, &qe_immr->cp.cecdr); +qe_iowrite32be ((cmd |QE_CR_FLG | ((u32 )device << dev_shift) | (u32 )mcn_protocol << mcn_shift), + &qe_immr->cp.cecr); }/* wait for the QE_CR_FLG to clear */ - ret =spin_event_timeout ((in_be32 (&qe_immr->cp.cecr) &QE_CR_FLG ) ==0 , -100 ,0 ); + ret =spin_event_timeout ((qe_ioread32be (&qe_immr->cp.cecr) &QE_CR_FLG ) ==0 , +100 ,0 );/* On timeout (e.g. failure), the expression will be false (ret == 0), otherwise it will be true (ret == 1). */ spin_unlock_irqrestore (&qe_lock, flags);
@@ -230,7 +229,7 @@ int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier) tempval = ((divisor -1 ) <<QE_BRGC_DIVISOR_SHIFT ) |QE_BRGC_ENABLE | div16; -out_be32 (&qe_immr->brg.brgc[brg -QE_BRG1 ], tempval); +qe_iowrite32be (tempval, &qe_immr->brg.brgc[brg -QE_BRG1 ]);return 0 ; }
@@ -377,9 +376,10 @@ static int qe_sdma_init(void)return -ENOMEM ; } -out_be32 (&sdma->sdebcr, (u32 ) sdma_buf_offset &QE_SDEBCR_BA_MASK ); -out_be32 (&sdma->sdmr, (QE_SDMR_GLB_1_MSK | - (0x1 <<QE_SDMR_CEN_SHIFT ))); +qe_iowrite32be ((u32 )sdma_buf_offset &QE_SDEBCR_BA_MASK , + &sdma->sdebcr); +qe_iowrite32be ((QE_SDMR_GLB_1_MSK | (0x1 <<QE_SDMR_CEN_SHIFT )), + &sdma->sdmr);return 0 ; }
@@ -417,14 +417,14 @@ static void qe_upload_microcode(const void *base, "uploading microcode '%s'\n", ucode->id);/* Use auto-increment */ -out_be32 (&qe_immr->iram.iadd,be32_to_cpu (ucode->iram_offset) | -QE_IRAM_IADD_AIE |QE_IRAM_IADD_BADDR ); +qe_iowrite32be (be32_to_cpu (ucode->iram_offset) |QE_IRAM_IADD_AIE |QE_IRAM_IADD_BADDR , + &qe_immr->iram.iadd);for (i =0 ; i <be32_to_cpu (ucode->count); i++) -out_be32 (&qe_immr->iram.idata,be32_to_cpu (code[i])); +qe_iowrite32be (be32_to_cpu (code[i]), &qe_immr->iram.idata);/* Set I-RAM Ready Register */ -out_be32 (&qe_immr->iram.iready,be32_to_cpu (QE_IRAM_READY )); +qe_iowrite32be (be32_to_cpu (QE_IRAM_READY ), &qe_immr->iram.iready); }/*
@@ -509,7 +509,7 @@ int qe_upload_firmware(const struct qe_firmware *firmware)* If the microcode calls for it, split the I-RAM. */ if (!firmware->split) -setbits16 (&qe_immr->cp.cercr,QE_CP_CERCR_CIR ); +qe_setbits_be16 (&qe_immr->cp.cercr,QE_CP_CERCR_CIR );if (firmware->soc.model) printk(KERN_INFO
@@ -543,11 +543,13 @@ int qe_upload_firmware(const struct qe_firmware *firmware)u32 trap =be32_to_cpu (ucode->traps[j]);if (trap) -out_be32 (&qe_immr->rsp[i].tibcr[j], trap); +qe_iowrite32be (trap, + &qe_immr->rsp[i].tibcr[j]); }/* Enable traps */ -out_be32 (&qe_immr->rsp[i].eccr,be32_to_cpu (ucode->eccr)); +qe_iowrite32be (be32_to_cpu (ucode->eccr), + &qe_immr->rsp[i].eccr); } qe_firmware_uploaded =1 ;
drivers/soc/fsl/qe/qe_ic.c +3 -2
@@ -24,6 +24,7 @@#include <linux/spinlock.h> #include <asm/irq.h> #include <asm/io.h> +#include <soc/fsl/qe/qe.h> #include <soc/fsl/qe/qe_ic.h> #include "qe_ic.h"
@@ -173,13 +174,13 @@ static struct qe_ic_info qe_ic_info[] = {static inline u32 qe_ic_read (__be32 __iomem *base,unsigned int reg) { -return in_be32 (base + (reg >>2 )); +return qe_ioread32be (base + (reg >>2 )); }static inline void qe_ic_write (__be32 __iomem *base,unsigned int reg,u32 value) { -out_be32 (base + (reg >>2 ), value); +qe_iowrite32be (value, base + (reg >>2 )); }static inline struct qe_ic *qe_ic_from_irq (unsigned int virq)
drivers/soc/fsl/qe/qe_io.c +18 -22
@@ -57,16 +57,16 @@ void __par_io_config_pin(struct qe_pio_regs __iomem *par_io, u8 pin, int dir, pin_mask1bit = (u32) (1 << (QE_PIO_PINS - (pin +1 )));/* Set open drain, if required */ - tmp_val =in_be32 (&par_io->cpodr); + tmp_val =qe_ioread32be (&par_io->cpodr);if (open_drain) -out_be32 (&par_io->cpodr, pin_mask1bit | tmp_val); +qe_iowrite32be (pin_mask1bit | tmp_val, &par_io->cpodr);else -out_be32 (&par_io->cpodr, ~pin_mask1bit & tmp_val); +qe_iowrite32be (~pin_mask1bit & tmp_val, &par_io->cpodr);/* define direction */ tmp_val = (pin > (QE_PIO_PINS /2 ) -1 ) ? -in_be32 (&par_io->cpdir2) : -in_be32 (&par_io->cpdir1); +qe_ioread32be (&par_io->cpdir2) : +qe_ioread32be (&par_io->cpdir1);/* get all bits mask for 2 bit per port */ pin_mask2bits = (u32) (0x3 << (QE_PIO_PINS -
@@ -78,34 +78,30 @@ void __par_io_config_pin(struct qe_pio_regs __iomem *par_io, u8 pin, int dir,/* clear and set 2 bits mask */ if (pin > (QE_PIO_PINS /2 ) -1 ) { -out_be32 (&par_io->cpdir2, - ~pin_mask2bits & tmp_val); +qe_iowrite32be (~pin_mask2bits & tmp_val, &par_io->cpdir2); tmp_val &= ~pin_mask2bits; -out_be32 (&par_io->cpdir2, new_mask2bits | tmp_val); +qe_iowrite32be (new_mask2bits | tmp_val, &par_io->cpdir2); }else { -out_be32 (&par_io->cpdir1, - ~pin_mask2bits & tmp_val); +qe_iowrite32be (~pin_mask2bits & tmp_val, &par_io->cpdir1); tmp_val &= ~pin_mask2bits; -out_be32 (&par_io->cpdir1, new_mask2bits | tmp_val); +qe_iowrite32be (new_mask2bits | tmp_val, &par_io->cpdir1); }/* define pin assignment */ tmp_val = (pin > (QE_PIO_PINS /2 ) -1 ) ? -in_be32 (&par_io->cppar2) : -in_be32 (&par_io->cppar1); +qe_ioread32be (&par_io->cppar2) : +qe_ioread32be (&par_io->cppar1); new_mask2bits = (u32) (assignment << (QE_PIO_PINS - (pin % (QE_PIO_PINS /2 ) +1 ) *2 ));/* clear and set 2 bits mask */ if (pin > (QE_PIO_PINS /2 ) -1 ) { -out_be32 (&par_io->cppar2, - ~pin_mask2bits & tmp_val); +qe_iowrite32be (~pin_mask2bits & tmp_val, &par_io->cppar2); tmp_val &= ~pin_mask2bits; -out_be32 (&par_io->cppar2, new_mask2bits | tmp_val); +qe_iowrite32be (new_mask2bits | tmp_val, &par_io->cppar2); }else { -out_be32 (&par_io->cppar1, - ~pin_mask2bits & tmp_val); +qe_iowrite32be (~pin_mask2bits & tmp_val, &par_io->cppar1); tmp_val &= ~pin_mask2bits; -out_be32 (&par_io->cppar1, new_mask2bits | tmp_val); +qe_iowrite32be (new_mask2bits | tmp_val, &par_io->cppar1); } }EXPORT_SYMBOL (__par_io_config_pin);
@@ -133,12 +129,12 @@ int par_io_data_set(u8 port, u8 pin, u8 val)/* calculate pin location */ pin_mask = (u32) (1 << (QE_PIO_PINS -1 - pin)); - tmp_val =in_be32 (&par_io[port].cpdata); + tmp_val =qe_ioread32be (&par_io[port].cpdata);if (val ==0 )/* clear */ -out_be32 (&par_io[port].cpdata, ~pin_mask & tmp_val); +qe_iowrite32be (~pin_mask & tmp_val, &par_io[port].cpdata);else /* set */ -out_be32 (&par_io[port].cpdata, pin_mask | tmp_val); +qe_iowrite32be (pin_mask | tmp_val, &par_io[port].cpdata);return 0 ; }
drivers/soc/fsl/qe/qe_tdm.c +4 -4
@@ -169,10 +169,10 @@ void ucc_tdm_init(struct ucc_tdm *utdm, struct ucc_tdm_info *ut_info) &siram[siram_entry_id * 32 + 0x200 + i]); } -setbits16 (&siram[(siram_entry_id *32 ) + (utdm->num_of_ts -1 )], -SIR_LAST ); -setbits16 (&siram[(siram_entry_id *32 ) +0x200 + (utdm->num_of_ts -1 )], -SIR_LAST ); +qe_setbits_be16 (&siram[(siram_entry_id *32 ) + (utdm->num_of_ts -1 )], +SIR_LAST ); +qe_setbits_be16 (&siram[(siram_entry_id *32 ) +0x200 + (utdm->num_of_ts -1 )], +SIR_LAST );/* Set SIxMR register */ sixmr =SIMR_SAD (siram_entry_id);
drivers/soc/fsl/qe/ucc.c +8 -8
@@ -35,8 +35,8 @@ int ucc_set_qe_mux_mii_mng(unsigned int ucc_num)return -EINVAL ;spin_lock_irqsave (&cmxgcr_lock, flags); -clrsetbits_be32 (&qe_immr->qmx.cmxgcr,QE_CMXGCR_MII_ENET_MNG , - ucc_num <<QE_CMXGCR_MII_ENET_MNG_SHIFT ); +qe_clrsetbits_be32 (&qe_immr->qmx.cmxgcr,QE_CMXGCR_MII_ENET_MNG , + ucc_num <<QE_CMXGCR_MII_ENET_MNG_SHIFT );spin_unlock_irqrestore (&cmxgcr_lock, flags);return 0 ;
@@ -80,8 +80,8 @@ int ucc_set_type(unsigned int ucc_num, enum ucc_speed_type speed)return -EINVAL ; } -clrsetbits_8 (guemr,UCC_GUEMR_MODE_MASK , -UCC_GUEMR_SET_RESERVED3 | speed); +qe_clrsetbits_8 (guemr,UCC_GUEMR_MODE_MASK , +UCC_GUEMR_SET_RESERVED3 | speed);return 0 ; }
@@ -109,9 +109,9 @@ int ucc_mux_set_grant_tsa_bkpt(unsigned int ucc_num, int set, u32 mask)get_cmxucr_reg (ucc_num, &cmxucr, ®_num, &shift);if (set) -setbits32 (cmxucr, mask << shift); +qe_setbits_be32 (cmxucr, mask << shift);else -clrbits32 (cmxucr, mask << shift); +qe_clrbits_be32 (cmxucr, mask << shift);return 0 ; }
@@ -207,8 +207,8 @@ int ucc_set_qe_mux_rxtx(unsigned int ucc_num, enum qe_clock clock,if (mode ==COMM_DIR_RX ) shift +=4 ; -clrsetbits_be32 (cmxucr,QE_CMXUCR_TX_CLK_SRC_MASK << shift, - clock_bits << shift); +qe_clrsetbits_be32 (cmxucr,QE_CMXUCR_TX_CLK_SRC_MASK << shift, + clock_bits << shift);return 0 ; }
drivers/soc/fsl/qe/ucc_fast.c +37 -34
149 lines not on this page · raw message
drivers/soc/fsl/qe/ucc_slow.c +19 -19
@@ -78,7 +78,7 @@ void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode) us_regs = uccs->us_regs;/* Enable reception and/or transmission on this UCC. */ - gumr_l =in_be32 (&us_regs->gumr_l); + gumr_l =qe_ioread32be (&us_regs->gumr_l);if (mode &COMM_DIR_TX ) { gumr_l |=UCC_SLOW_GUMR_L_ENT ; uccs->enabled_tx =1 ;
@@ -87,7 +87,7 @@ void ucc_slow_enable(struct ucc_slow_private * uccs, enum comm_dir mode) gumr_l |=UCC_SLOW_GUMR_L_ENR ; uccs->enabled_rx =1 ; } -out_be32 (&us_regs->gumr_l, gumr_l); +qe_iowrite32be (gumr_l, &us_regs->gumr_l); }EXPORT_SYMBOL (ucc_slow_enable);
@@ -99,7 +99,7 @@ void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode) us_regs = uccs->us_regs;/* Disable reception and/or transmission on this UCC. */ - gumr_l =in_be32 (&us_regs->gumr_l); + gumr_l =qe_ioread32be (&us_regs->gumr_l);if (mode &COMM_DIR_TX ) { gumr_l &= ~UCC_SLOW_GUMR_L_ENT ; uccs->enabled_tx =0 ;
@@ -108,7 +108,7 @@ void ucc_slow_disable(struct ucc_slow_private * uccs, enum comm_dir mode) gumr_l &= ~UCC_SLOW_GUMR_L_ENR ; uccs->enabled_rx =0 ; } -out_be32 (&us_regs->gumr_l, gumr_l); +qe_iowrite32be (gumr_l, &us_regs->gumr_l); }EXPORT_SYMBOL (ucc_slow_disable);
@@ -198,7 +198,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** uccreturn ret; } -out_be16 (&uccs->us_pram->mrblr, us_info->max_rx_buf_length); +qe_iowrite16be (us_info->max_rx_buf_length, &uccs->us_pram->mrblr);INIT_LIST_HEAD (&uccs->confQ);
@@ -228,27 +228,27 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc bd = uccs->confBd = uccs->tx_bd =qe_muram_addr (uccs->tx_base_offset);for (i =0 ; i < us_info->tx_bd_ring_len -1 ; i++) {/* clear bd buffer */ -out_be32 (&bd->buf,0 ); +qe_iowrite32be (0 , &bd->buf);/* set bd status and length */ -out_be32 ((u32 *) bd,0 ); +qe_iowrite32be (0 , (u32 *)bd); bd++; }/* for last BD set Wrap bit */ -out_be32 (&bd->buf,0 ); -out_be32 ((u32 *) bd,cpu_to_be32 (T_W )); +qe_iowrite32be (0 , &bd->buf); +qe_iowrite32be (cpu_to_be32 (T_W ), (u32 *)bd);/* Init Rx bds */ bd = uccs->rx_bd =qe_muram_addr (uccs->rx_base_offset);for (i =0 ; i < us_info->rx_bd_ring_len -1 ; i++) {/* set bd status and length */ -out_be32 ((u32 *)bd,0 ); +qe_iowrite32be (0 , (u32 *)bd);/* clear bd buffer */ -out_be32 (&bd->buf,0 ); +qe_iowrite32be (0 , &bd->buf); bd++; }/* for last BD set Wrap bit */ -out_be32 ((u32 *)bd,cpu_to_be32 (R_W )); -out_be32 (&bd->buf,0 ); +qe_iowrite32be (cpu_to_be32 (R_W ), (u32 *)bd); +qe_iowrite32be (0 , &bd->buf);/* Set GUMR (For more details see the hardware spec.). */ /* gumr_h */
@@ -269,7 +269,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc gumr |=UCC_SLOW_GUMR_H_TXSY ;if (us_info->rtsm) gumr |=UCC_SLOW_GUMR_H_RTSM ; -out_be32 (&us_regs->gumr_h, gumr); +qe_iowrite32be (gumr, &us_regs->gumr_h);/* gumr_l */ gumr = us_info->tdcr | us_info->rdcr | us_info->tenc | us_info->renc |
@@ -282,7 +282,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc gumr |=UCC_SLOW_GUMR_L_TINV ;if (us_info->tend) gumr |=UCC_SLOW_GUMR_L_TEND ; -out_be32 (&us_regs->gumr_l, gumr); +qe_iowrite32be (gumr, &us_regs->gumr_l);/* Function code registers */
@@ -292,8 +292,8 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc uccs->us_pram->rbmr =UCC_BMR_BO_BE ;/* rbase, tbase are offsets from MURAM base */ -out_be16 (&uccs->us_pram->rbase, uccs->rx_base_offset); -out_be16 (&uccs->us_pram->tbase, uccs->tx_base_offset); +qe_iowrite16be (uccs->rx_base_offset, &uccs->us_pram->rbase); +qe_iowrite16be (uccs->tx_base_offset, &uccs->us_pram->tbase);/* Mux clocking */ /* Grant Support */
@@ -323,14 +323,14 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc }/* Set interrupt mask register at UCC level. */ -out_be16 (&us_regs->uccm, us_info->uccm_mask); +qe_iowrite16be (us_info->uccm_mask, &us_regs->uccm);/* First, clear anything pending at UCC level, * otherwise, old garbage may come through * as soon as the dam is opened. */ /* Writing '1' clears */ -out_be16 (&us_regs->ucce,0xffff ); +qe_iowrite16be (0xffff , &us_regs->ucce);/* Issue QE Init command */ if (us_info->init_tx && us_info->init_rx)
drivers/soc/fsl/qe/usb.c +1 -1
@@ -43,7 +43,7 @@ int qe_usb_clock_set(enum qe_clock clk, int rate)spin_lock_irqsave (&cmxgcr_lock, flags); -clrsetbits_be32 (&mux->cmxgcr,QE_CMXGCR_USBCS , val); +qe_clrsetbits_be32 (&mux->cmxgcr,QE_CMXGCR_USBCS , val);spin_unlock_irqrestore (&cmxgcr_lock, flags);
Signature · 1 line
2.23.0
PATCH v4 6/47 soc: fsl: qe: replace spin_event_timeout by readx_poll_timeout_atomic
In reply to Rasmus VillemoesIn preparation for allowing QE to be built for architectures other than ppc, use the generic readx_poll_timeout_atomic() helper from iopoll.h rather than the ppc-only spin_event_timeout().
--- drivers/soc/fsl/qe/qe.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/soc/fsl/qe/qe.c +7 -6
@@ -22,6 +22,7 @@#include <linux/module.h> #include <linux/delay.h> #include <linux/ioport.h> +#include <linux/iopoll.h> #include <linux/crc32.h> #include <linux/mod_devicetable.h> #include <linux/of_platform.h>
@@ -108,7 +109,8 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input) {unsigned long flags;u8 mcn_shift =0 , dev_shift =0 ; -u32 ret; +u32 val; +int ret;spin_lock_irqsave (&qe_lock, flags);if (cmd ==QE_RESET ) {
@@ -135,13 +137,12 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input) }/* wait for the QE_CR_FLG to clear */ - ret =spin_event_timeout ((qe_ioread32be (&qe_immr->cp.cecr) &QE_CR_FLG ) ==0 , -100 ,0 ); -/* On timeout (e.g. failure), the expression will be false (ret == 0), -otherwise it will be true (ret == 1). */ + ret =readx_poll_timeout_atomic (qe_ioread32be, &qe_immr->cp.cecr, val, + (val &QE_CR_FLG ) ==0 ,0 ,100 ); +/* On timeout, ret is -ETIMEDOUT, otherwise it will be 0. */ spin_unlock_irqrestore (&qe_lock, flags); -return ret ==1 ; +return ret ==0 ; }EXPORT_SYMBOL (qe_issue_cmd);
Signature · 1 line
2.23.0
PATCH v4 7/47 soc: fsl: qe: qe.c: guard use of pvr_version_is() with CONFIG_PPC32
In reply to Rasmus VillemoesCommit e5c5c8d23fef (soc/fsl/qe: only apply QE_General4 workaround on affected SoCs) introduced use of pvr_version_is(), saying
The QE_General4 workaround is only valid for the MPC832x and MPC836x SoCs. The other SoCs that embed a QUICC engine are not affected by this hardware bug and thus can use the computed divisors (this was successfully tested on the T1040).
I'm reading the above as saying that the errata does not apply to the ARM-based SOCs with QUICC engine. In any case, use of pvr_version_is() must be guarded by CONFIG_PPC32 before we can remove the PPC32 dependency from CONFIG_QUICC_ENGINE, so introduce qe_general4_errata() to keep the necessary #ifdeffery localized to a trivial helper.
--- drivers/soc/fsl/qe/qe.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/soc/fsl/qe/qe.c +9 -1
@@ -197,6 +197,14 @@ EXPORT_SYMBOL(qe_get_brg_clk);#define PVR_VER_836x 0x8083#define PVR_VER_832x 0x8084 +static bool qe_general4_errata (void ) +{ +#ifdef CONFIG_PPC32 +return pvr_version_is (PVR_VER_836x) ||pvr_version_is (PVR_VER_832x); +#endif +return false; +} +/* Program the BRG to the given sampling rate and multiplier * * @brg: the BRG, QE_BRG1 - QE_BRG16
@@ -223,7 +231,7 @@ int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier)/* Errata QE_General4, which affects some MPC832x and MPC836x SOCs, says that the BRG divisor must be even if you're not using divide-by-16 mode. */ -if (pvr_version_is (PVR_VER_836x) ||pvr_version_is (PVR_VER_832x)) +if (qe_general4_errata ())if (!div16 && (divisor &1 ) && (divisor >3 )) divisor++;
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Timur Tabi
maintainerRe: [PATCH v4 07/47] soc: fsl: qe: qe.c: guard use of pvr_version_is() with CONFIG_PPC32
Quoted 13 lines · Rasmus Villemoes
drivers/soc/fsl/qe/qe.c +8
-0+static bool qe_general4_errata (void ) +{ +#ifdef CONFIG_PPC32 +return pvr_version_is (PVR_VER_836x) ||pvr_version_is (PVR_VER_832x); +#endif +return false; +} +/* Program the BRG to the given sampling rate and multiplier * * @brg: the BRG, QE_BRG1 - QE_BRG16
drivers/soc/fsl/qe/qe.c int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier) · line 233
Quoted 3 lines
drivers/soc/fsl/qe/qe.c +0
-0@@ -223,7 +231,7 @@ int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier)/* Errata QE_General4, which affects some MPC832x and MPC836x SOCs, says that the BRG divisor must be even if you're not using divide-by-16 mode. */
Can you also move this comment (and fix the comment formatting so that it's a proper function comment) to qe_general4_errata()?
Re: [PATCH v4 07/47] soc: fsl: qe: qe.c: guard use of pvr_version_is() with CONFIG_PPC32
Quoted 13 lines · Timur Tabi
Quoted 11 lines · Rasmus Villemoes
drivers/soc/fsl/qe/qe.c +8
-0+static bool qe_general4_errata (void ) +{ +#ifdef CONFIG_PPC32 +return pvr_version_is (PVR_VER_836x) ||pvr_version_is (PVR_VER_832x); +#endif +return false; +} +/* Program the BRG to the given sampling rate and multiplier *
Quoted 9 lines
drivers/soc/fsl/qe/qe.c int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier) · line 233
Quoted 5 lines
* @brg: the BRG,
QE_BRG1-QE_BRG16drivers/soc/fsl/qe/qe.c +0
-0@@ -223,7 +231,7 @@ int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier)/* Errata QE_General4, which affects some MPC832x and MPC836x SOCs, says that the BRG divisor must be even if you're not using divide-by-16 mode. */ Can you also move this comment (and fix the comment formatting so that it's a proper function comment) to
qe_general4_errata()?
I actually thought of doing that, but decided against it because the comment not only mentions the SOCs affected, but also explains the following math/logic. I mean, without that comment nearby, the code is
if (qe_general4_errata())
if (some weird condition)
divisor++;
In contrast, I think the qe_general4_errata() is pretty self-explanatory
- is this a SOC affected by that errata (whatever that errata may be about and what the software workaround is).
Rasmus
PATCH v4 8/47 soc: fsl: qe: drop unneeded #includes
In reply to Rasmus VillemoesThese includes are not actually needed, and asm/rheap.h and sysdev/fsl_soc.h are PPC-specific, hence prevent compiling QE for other architectures.
--- drivers/soc/fsl/qe/qe.c | 5 ----- drivers/soc/fsl/qe/qe_io.c | 2 -- 2 files changed, 7 deletions(-)
drivers/soc/fsl/qe/qe.c +0 -5
@@ -26,13 +26,8 @@#include <linux/crc32.h> #include <linux/mod_devicetable.h> #include <linux/of_platform.h> -#include <asm/irq.h> -#include <asm/page.h> -#include <asm/pgtable.h> #include <soc/fsl/qe/immap_qe.h> #include <soc/fsl/qe/qe.h> -#include <asm/prom.h> -#include <asm/rheap.h> static void qe_snums_init (void );static int qe_sdma_init (void );
drivers/soc/fsl/qe/qe_io.c +0 -2
@@ -18,8 +18,6 @@#include <asm/io.h> #include <soc/fsl/qe/qe.h> -#include <asm/prom.h> -#include <sysdev/fsl_soc.h> #undef DEBUG
Signature · 7 lines
2.23.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v4 9/47 soc: fsl: qe: drop assign-only high_active in qe_ic_init
In reply to Rasmus Villemoeshigh_active is only assigned to but never used. Remove it.
--- drivers/soc/fsl/qe/qe_ic.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +2 -4
@@ -320,7 +320,7 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags, {struct qe_ic *qe_ic;struct resource res; -u32 temp =0 , ret, high_active =0 ; +u32 temp =0 , ret; ret =of_address_to_resource (node,0 , &res);if (ret)
@@ -366,10 +366,8 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags, temp |=CICR_GRTB ;/* choose destination signal for highest priority interrupt */ -if (flags &QE_IC_HIGH_SIGNAL ) { +if (flags &QE_IC_HIGH_SIGNAL ) temp |= (SIGNAL_HIGH <<CICR_HPIT_SHIFT ); - high_active =1 ; - }qe_ic_write (qe_ic->regs,QEIC_CICR , temp);
Signature · 1 line
2.23.0
PATCH v4 10/47 soc: fsl: qe: remove pointless sysfs registration in qe_ic.c
In reply to Rasmus VillemoesThere's no point in registering with sysfs when that doesn't actually allow any interaction with the device or driver (no uevents, no sysfs files that provide information or allow configuration, no nothing).
--- drivers/soc/fsl/qe/qe_ic.c | 31 ------------------------------- 1 file changed, 31 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +0 -31
@@ -474,34 +474,3 @@ int qe_ic_set_high_priority(unsigned int virq, unsigned int priority, int high)return 0 ; } - -static struct bus_type qe_ic_subsys = { - .name ="qe_ic" , - .dev_name ="qe_ic" , -}; - -static struct device device_qe_ic = { - .id =0 , - .bus = &qe_ic_subsys, -}; - -static int __init init_qe_ic_sysfs (void ) -{ -int rc; - -printk (KERN_DEBUG "Registering qe_ic with sysfs...\n" ); - - rc =subsys_system_register (&qe_ic_subsys,NULL ); -if (rc) { -printk (KERN_ERR "Failed registering qe_ic sys class\n" ); -return -ENODEV ; - } - rc =device_register (&device_qe_ic); -if (rc) { -printk (KERN_ERR "Failed registering qe_ic sys device\n" ); -return -ENODEV ; - } -return 0 ; -} - -subsys_initcall (init_qe_ic_sysfs);
Signature · 1 line
2.23.0
PATCH v4 11/47 soc: fsl: qe: use qe_ic_cascade_{low,high}_mpic also on 83xx
In reply to Rasmus VillemoesThe *_ipic and *_mpic handlers are almost identical - the only difference is that the latter end with an unconditional chip->irq_eoi() call. Since IPIC does not have ->irq_eoi, we can reduce some code duplication by calling irq_eoi conditionally.
This is similar to what is already done in mpc8xxx_gpio_irq_cascade().
This leaves the functions slightly misnamed, but that will be fixed in a subsequent patch.
--- arch/powerpc/platforms/83xx/misc.c | 2 +- include/soc/fsl/qe/qe_ic.h | 24 ++++-------------------- 2 files changed, 5 insertions(+), 21 deletions(-)
arch/powerpc/platforms/83xx/misc.c +1 -1
@@ -100,7 +100,7 @@ void __init mpc83xx_qe_init_IRQ(void)if (!np)return ; } -qe_ic_init (np,0 , qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic); +qe_ic_init (np,0 , qe_ic_cascade_low_mpic, qe_ic_cascade_high_mpic);of_node_put (np); }
include/soc/fsl/qe/qe_ic.h +4 -20
@@ -74,24 +74,6 @@ void qe_ic_set_highest_priority(unsigned int virq, int high);int qe_ic_set_priority (unsigned int virq,unsigned int priority);int qe_ic_set_high_priority (unsigned int virq,unsigned int priority,int high); -static inline void qe_ic_cascade_low_ipic (struct irq_desc *desc) -{ -struct qe_ic *qe_ic =irq_desc_get_handler_data (desc); -unsigned int cascade_irq =qe_ic_get_low_irq (qe_ic); - -if (cascade_irq !=NO_IRQ ) -generic_handle_irq (cascade_irq); -} - -static inline void qe_ic_cascade_high_ipic (struct irq_desc *desc) -{ -struct qe_ic *qe_ic =irq_desc_get_handler_data (desc); -unsigned int cascade_irq =qe_ic_get_high_irq (qe_ic); - -if (cascade_irq !=NO_IRQ ) -generic_handle_irq (cascade_irq); -} -static inline void qe_ic_cascade_low_mpic (struct irq_desc *desc) {struct qe_ic *qe_ic =irq_desc_get_handler_data (desc);
@@ -101,7 +83,8 @@ static inline void qe_ic_cascade_low_mpic(struct irq_desc *desc)if (cascade_irq !=NO_IRQ )generic_handle_irq (cascade_irq); - chip->irq_eoi (&desc->irq_data); +if (chip->irq_eoi) + chip->irq_eoi (&desc->irq_data); }static inline void qe_ic_cascade_high_mpic (struct irq_desc *desc)
@@ -113,7 +96,8 @@ static inline void qe_ic_cascade_high_mpic(struct irq_desc *desc)if (cascade_irq !=NO_IRQ )generic_handle_irq (cascade_irq); - chip->irq_eoi (&desc->irq_data); +if (chip->irq_eoi) + chip->irq_eoi (&desc->irq_data); }static inline void qe_ic_cascade_muxed_mpic (struct irq_desc *desc)
Signature · 1 line
2.23.0
PATCH v4 12/47 soc: fsl: qe: move calls of qe_ic_init out of arch/powerpc/
In reply to Rasmus VillemoesHaving to call qe_ic_init() from platform-specific code makes it awkward to allow building the QE drivers for ARM. It's also a needless duplication of code, and slightly error-prone: Instead of the caller needing to know the details of whether the QUICC Engine High and QUICC Engine Low are actually the same interrupt (see e.g. the machine_is() in mpc85xx_mds_qeic_init), just let the init function choose the appropriate handlers after it has parsed the DT and figured it out. If the two interrupts are distinct, use separate handlers, otherwise use the handler which first checks the CHIVEC register (for the high priority interrupts), then the CIVEC.
All existing callers pass 0 for flags, so continue to do that from the new single caller. Later cleanups will remove that argument from qe_ic_init and simplify the body, as well as make qe_ic_init into a proper init function for an IRQCHIP_DECLARE, eliminating the need to manually look up the fsl,qe-ic node.
--- arch/powerpc/platforms/83xx/km83xx.c | 1 - arch/powerpc/platforms/83xx/misc.c | 16 ---------- arch/powerpc/platforms/83xx/mpc832x_mds.c | 1 - arch/powerpc/platforms/83xx/mpc832x_rdb.c | 1 - arch/powerpc/platforms/83xx/mpc836x_mds.c | 1 - arch/powerpc/platforms/83xx/mpc836x_rdk.c | 1 - arch/powerpc/platforms/83xx/mpc83xx.h | 2 -- arch/powerpc/platforms/85xx/corenet_generic.c | 10 ------- arch/powerpc/platforms/85xx/mpc85xx_mds.c | 27 ----------------- arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 17 ----------- arch/powerpc/platforms/85xx/twr_p102x.c | 15 ---------- drivers/soc/fsl/qe/qe_ic.c | 29 +++++++++++++++++-- include/soc/fsl/qe/qe_ic.h | 7 ----- 13 files changed, 26 insertions(+), 102 deletions(-)
arch/powerpc/platforms/83xx/km83xx.c +0 -1
@@ -34,7 +34,6 @@#include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include "mpc83xx.h"
arch/powerpc/platforms/83xx/misc.c +0 -16
@@ -14,7 +14,6 @@#include <asm/io.h> #include <asm/hw_irq.h> #include <asm/ipic.h> -#include <soc/fsl/qe/qe_ic.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h>
@@ -90,24 +89,9 @@ void __init mpc83xx_ipic_init_IRQ(void) }#ifdef CONFIG_QUICC_ENGINE -void __init mpc83xx_qe_init_IRQ (void ) -{ -struct device_node *np; - - np =of_find_compatible_node (NULL ,NULL ,"fsl,qe-ic" ); -if (!np) { - np =of_find_node_by_type (NULL ,"qeic" ); -if (!np) -return ; - } -qe_ic_init (np,0 , qe_ic_cascade_low_mpic, qe_ic_cascade_high_mpic); -of_node_put (np); -} -void __init mpc83xx_ipic_and_qe_init_IRQ (void ) {mpc83xx_ipic_init_IRQ (); -mpc83xx_qe_init_IRQ (); }#endif /* CONFIG_QUICC_ENGINE */
arch/powerpc/platforms/83xx/mpc832x_mds.c +0 -1
@@ -33,7 +33,6 @@#include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include "mpc83xx.h"
arch/powerpc/platforms/83xx/mpc832x_rdb.c +0 -1
@@ -22,7 +22,6 @@#include <asm/ipic.h> #include <asm/udbg.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h>
arch/powerpc/platforms/83xx/mpc836x_mds.c +0 -1
@@ -41,7 +41,6 @@#include <sysdev/fsl_pci.h> #include <sysdev/simple_gpio.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include "mpc83xx.h"
arch/powerpc/platforms/83xx/mpc836x_rdk.c +0 -1
@@ -17,7 +17,6 @@#include <asm/ipic.h> #include <asm/udbg.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h>
arch/powerpc/platforms/83xx/mpc83xx.h +0 -2
@@ -73,10 +73,8 @@ extern int mpc834x_usb_cfg(void);extern int mpc831x_usb_cfg (void );extern void mpc83xx_ipic_init_IRQ (void );#ifdef CONFIG_QUICC_ENGINE -extern void mpc83xx_qe_init_IRQ (void );extern void mpc83xx_ipic_and_qe_init_IRQ (void );#else -static inline void __init mpc83xx_qe_init_IRQ (void ) {}#define mpc83xx_ipic_and_qe_init_IRQ mpc83xx_ipic_init_IRQ#endif /* CONFIG_QUICC_ENGINE */
arch/powerpc/platforms/85xx/corenet_generic.c +0 -10
@@ -24,7 +24,6 @@#include <asm/mpic.h> #include <asm/ehv_pic.h> #include <asm/swiotlb.h> -#include <soc/fsl/qe/qe_ic.h> #include <linux/of_platform.h> #include <sysdev/fsl_soc.h>
@@ -38,8 +37,6 @@ void __init corenet_gen_pic_init(void)unsigned int flags =MPIC_BIG_ENDIAN |MPIC_SINGLE_DEST_CPU |MPIC_NO_RESET ; -struct device_node *np; -if (ppc_md.get_irq == mpic_get_coreint_irq) flags |=MPIC_ENABLE_COREINT ;
@@ -47,13 +44,6 @@ void __init corenet_gen_pic_init(void)BUG_ON (mpic ==NULL );mpic_init (mpic); - - np =of_find_compatible_node (NULL ,NULL ,"fsl,qe-ic" ); -if (np) { -qe_ic_init (np,0 , qe_ic_cascade_low_mpic, - qe_ic_cascade_high_mpic); -of_node_put (np); - } }/*
arch/powerpc/platforms/85xx/mpc85xx_mds.c +0 -27
@@ -45,7 +45,6 @@#include <sysdev/fsl_pci.h> #include <sysdev/simple_gpio.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include <asm/mpic.h> #include <asm/swiotlb.h> #include "smp.h"
@@ -270,33 +269,8 @@ static void __init mpc85xx_mds_qe_init(void) } } -static void __init mpc85xx_mds_qeic_init (void ) -{ -struct device_node *np; - - np =of_find_compatible_node (NULL ,NULL ,"fsl,qe" ); -if (!of_device_is_available (np)) { -of_node_put (np); -return ; - } - - np =of_find_compatible_node (NULL ,NULL ,"fsl,qe-ic" ); -if (!np) { - np =of_find_node_by_type (NULL ,"qeic" ); -if (!np) -return ; - } - -if (machine_is (p1021_mds)) -qe_ic_init (np,0 , qe_ic_cascade_low_mpic, - qe_ic_cascade_high_mpic); -else -qe_ic_init (np,0 , qe_ic_cascade_muxed_mpic,NULL ); -of_node_put (np); -}#else static void __init mpc85xx_mds_qe_init (void ) { } -static void __init mpc85xx_mds_qeic_init (void ) { }#endif /* CONFIG_QUICC_ENGINE */ static void __init mpc85xx_mds_setup_arch (void )
@@ -371,7 +345,6 @@ static void __init mpc85xx_mds_pic_init(void)BUG_ON (mpic ==NULL );mpic_init (mpic); -mpc85xx_mds_qeic_init (); }static int __init mpc85xx_mds_probe (void )
arch/powerpc/platforms/85xx/mpc85xx_rdb.c +0 -17
@@ -23,7 +23,6 @@#include <asm/udbg.h> #include <asm/mpic.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h>
@@ -44,10 +43,6 @@ void __init mpc85xx_rdb_pic_init(void) {struct mpic *mpic; -#ifdef CONFIG_QUICC_ENGINE -struct device_node *np; -#endif -if (of_machine_is_compatible ("fsl,MPC85XXRDB-CAMP" )) { mpic = mpic_alloc(NULL, 0, MPIC_NO_RESET | MPIC_BIG_ENDIAN |
@@ -62,18 +57,6 @@ void __init mpc85xx_rdb_pic_init(void)BUG_ON (mpic ==NULL );mpic_init (mpic); - -#ifdef CONFIG_QUICC_ENGINE - np =of_find_compatible_node (NULL ,NULL ,"fsl,qe-ic" ); -if (np) { -qe_ic_init (np,0 , qe_ic_cascade_low_mpic, - qe_ic_cascade_high_mpic); -of_node_put (np); - - }else -pr_err ("%s: Could not find qe-ic node\n" , __func__); -#endif - }/*
arch/powerpc/platforms/85xx/twr_p102x.c +0 -15
@@ -19,7 +19,6 @@#include <asm/udbg.h> #include <asm/mpic.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> #include <sysdev/fsl_soc.h> #include <sysdev/fsl_pci.h>
@@ -31,26 +30,12 @@ static void __init twr_p1025_pic_init(void) {struct mpic *mpic; -#ifdef CONFIG_QUICC_ENGINE -struct device_node *np; -#endif - mpic =mpic_alloc (NULL ,0 ,MPIC_BIG_ENDIAN |MPIC_SINGLE_DEST_CPU ,0 ,256 ," OpenPIC " );BUG_ON (mpic ==NULL );mpic_init (mpic); - -#ifdef CONFIG_QUICC_ENGINE - np =of_find_compatible_node (NULL ,NULL ,"fsl,qe-ic" ); -if (np) { -qe_ic_init (np,0 , qe_ic_cascade_low_mpic, - qe_ic_cascade_high_mpic); -of_node_put (np); - }else -pr_err ("Could not find qe-ic node\n" ); -#endif }/* ************************************************************************
drivers/soc/fsl/qe/qe_ic.c +26 -3
@@ -314,10 +314,10 @@ unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)return irq_linear_revmap (qe_ic->irqhost, irq); } -void __init qe_ic_init (struct device_node *node,unsigned int flags, -void (*low_handler)(struct irq_desc *desc), -void (*high_handler)(struct irq_desc *desc)) +static void __init qe_ic_init (struct device_node *node,unsigned int flags) { +void (*low_handler)(struct irq_desc *desc); +void (*high_handler)(struct irq_desc *desc);struct qe_ic *qe_ic;struct resource res;u32 temp =0 , ret;
@@ -349,6 +349,13 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags,kfree (qe_ic);return ; } +if (qe_ic->virq_high != qe_ic->virq_low) { + low_handler = qe_ic_cascade_low_mpic; + high_handler = qe_ic_cascade_high_mpic; + }else { + low_handler = qe_ic_cascade_muxed_mpic; + high_handler =NULL ; + }/* default priority scheme is grouped. If spread mode is */ /* required, configure cicr accordingly. */
@@ -381,6 +388,22 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags, } } +static int __init qe_ic_of_init (void ) +{ +struct device_node *np; + + np =of_find_compatible_node (NULL ,NULL ,"fsl,qe-ic" ); +if (!np) { + np =of_find_node_by_type (NULL ,"qeic" ); +if (!np) +return -ENODEV ; + } +qe_ic_init (np,0 ); +of_node_put (np); +return 0 ; +} +subsys_initcall (qe_ic_of_init); +void qe_ic_set_highest_priority (unsigned int virq,int high) {struct qe_ic *qe_ic =qe_ic_from_irq (virq);
include/soc/fsl/qe/qe_ic.h +0 -7
@@ -54,16 +54,9 @@ enum qe_ic_grp_id { };#ifdef CONFIG_QUICC_ENGINE -void qe_ic_init (struct device_node *node,unsigned int flags, -void (*low_handler)(struct irq_desc *desc), -void (*high_handler)(struct irq_desc *desc));unsigned int qe_ic_get_low_irq (struct qe_ic *qe_ic);unsigned int qe_ic_get_high_irq (struct qe_ic *qe_ic);#else -static inline void qe_ic_init (struct device_node *node,unsigned int flags, -void (*low_handler)(struct irq_desc *desc), -void (*high_handler)(struct irq_desc *desc)) -{}static inline unsigned int qe_ic_get_low_irq (struct qe_ic *qe_ic) {return 0 ; }static inline unsigned int qe_ic_get_high_irq (struct qe_ic *qe_ic)
Signature · 1 line
2.23.0
PATCH v4 13/47 powerpc/83xx: remove mpc83xx_ipic_and_qe_init_IRQ
In reply to Rasmus VillemoesThis is now exactly the same as mpc83xx_ipic_init_IRQ, so just use that directly.
--- arch/powerpc/platforms/83xx/km83xx.c | 2 +- arch/powerpc/platforms/83xx/misc.c | 7 ------- arch/powerpc/platforms/83xx/mpc832x_mds.c | 2 +- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 2 +- arch/powerpc/platforms/83xx/mpc836x_mds.c | 2 +- arch/powerpc/platforms/83xx/mpc836x_rdk.c | 2 +- arch/powerpc/platforms/83xx/mpc83xx.h | 5 ----- 7 files changed, 5 insertions(+), 17 deletions(-)
arch/powerpc/platforms/83xx/km83xx.c +1 -1
@@ -177,7 +177,7 @@ define_machine(mpc83xx_km) { .name = "mpc83xx-km-platform", .probe = mpc83xx_km_probe, .setup_arch = mpc83xx_km_setup_arch, - .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ, + .init_IRQ = mpc83xx_ipic_init_IRQ, .get_irq = ipic_get_irq, .restart = mpc83xx_restart, .time_init = mpc83xx_time_init,
arch/powerpc/platforms/83xx/misc.c +0 -7
@@ -88,13 +88,6 @@ void __init mpc83xx_ipic_init_IRQ(void)ipic_set_default_priority (); } -#ifdef CONFIG_QUICC_ENGINE -void __init mpc83xx_ipic_and_qe_init_IRQ (void ) -{ -mpc83xx_ipic_init_IRQ (); -} -#endif /* CONFIG_QUICC_ENGINE */ -static const struct of_device_id of_bus_ids[]__initconst = { { .type ="soc" , }, { .compatible ="soc" , },
arch/powerpc/platforms/83xx/mpc832x_mds.c +1 -1
@@ -101,7 +101,7 @@ define_machine(mpc832x_mds) { .name = "MPC832x MDS", .probe = mpc832x_sys_probe, .setup_arch = mpc832x_sys_setup_arch, - .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ, + .init_IRQ = mpc83xx_ipic_init_IRQ, .get_irq = ipic_get_irq, .restart = mpc83xx_restart, .time_init = mpc83xx_time_init,
arch/powerpc/platforms/83xx/mpc832x_rdb.c +1 -1
@@ -219,7 +219,7 @@ define_machine(mpc832x_rdb) { .name = "MPC832x RDB", .probe = mpc832x_rdb_probe, .setup_arch = mpc832x_rdb_setup_arch, - .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ, + .init_IRQ = mpc83xx_ipic_init_IRQ, .get_irq = ipic_get_irq, .restart = mpc83xx_restart, .time_init = mpc83xx_time_init,
arch/powerpc/platforms/83xx/mpc836x_mds.c +1 -1
@@ -208,7 +208,7 @@ define_machine(mpc836x_mds) { .name = "MPC836x MDS", .probe = mpc836x_mds_probe, .setup_arch = mpc836x_mds_setup_arch, - .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ, + .init_IRQ = mpc83xx_ipic_init_IRQ, .get_irq = ipic_get_irq, .restart = mpc83xx_restart, .time_init = mpc83xx_time_init,
arch/powerpc/platforms/83xx/mpc836x_rdk.c +1 -1
@@ -41,7 +41,7 @@ define_machine(mpc836x_rdk) { .name = "MPC836x RDK", .probe = mpc836x_rdk_probe, .setup_arch = mpc836x_rdk_setup_arch, - .init_IRQ = mpc83xx_ipic_and_qe_init_IRQ, + .init_IRQ = mpc83xx_ipic_init_IRQ, .get_irq = ipic_get_irq, .restart = mpc83xx_restart, .time_init = mpc83xx_time_init,
arch/powerpc/platforms/83xx/mpc83xx.h +0 -5
@@ -72,11 +72,6 @@ extern int mpc837x_usb_cfg(void);extern int mpc834x_usb_cfg (void );extern int mpc831x_usb_cfg (void );extern void mpc83xx_ipic_init_IRQ (void ); -#ifdef CONFIG_QUICC_ENGINE -extern void mpc83xx_ipic_and_qe_init_IRQ (void ); -#else -#define mpc83xx_ipic_and_qe_init_IRQ mpc83xx_ipic_init_IRQ -#endif /* CONFIG_QUICC_ENGINE */ #ifdef CONFIG_PCI extern void mpc83xx_setup_pci (void );
Signature · 1 line
2.23.0
PATCH v4 14/47 powerpc/85xx: remove mostly pointless mpc85xx_qe_init()
In reply to Rasmus VillemoesSince commit 302c059f2e7b (QE: use subsys_initcall to init qe), mpc85xx_qe_init() has done nothing apart from possibly emitting a pr_err(). As part of reducing the amount of QE-related code in arch/powerpc/ (and eventually support QE on other architectures), remove this low-hanging fruit.
--- arch/powerpc/platforms/85xx/common.c | 23 ------------------- arch/powerpc/platforms/85xx/corenet_generic.c | 2 -- arch/powerpc/platforms/85xx/mpc85xx.h | 2 -- arch/powerpc/platforms/85xx/mpc85xx_mds.c | 1 - arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 1 - arch/powerpc/platforms/85xx/twr_p102x.c | 1 - 6 files changed, 30 deletions(-)
arch/powerpc/platforms/85xx/common.c +0 -23
@@ -86,29 +86,6 @@ void __init mpc85xx_cpm2_pic_init(void)#endif #ifdef CONFIG_QUICC_ENGINE -void __init mpc85xx_qe_init (void ) -{ -struct device_node *np; - - np =of_find_compatible_node (NULL ,NULL ,"fsl,qe" ); -if (!np) { - np =of_find_node_by_name (NULL ,"qe" ); -if (!np) { -pr_err ("%s: Could not find Quicc Engine node\n" , - __func__); -return ; - } - } - -if (!of_device_is_available (np)) { -of_node_put (np); -return ; - } - -of_node_put (np); - -} -void __init mpc85xx_qe_par_io_init (void ) {struct device_node *np;
arch/powerpc/platforms/85xx/corenet_generic.c +0 -2
@@ -56,8 +56,6 @@ void __init corenet_gen_setup_arch(void)swiotlb_detect_4g ();pr_info ("%s board\n" , ppc_md.name); - -mpc85xx_qe_init (); }static const struct of_device_id of_device_ids[] = {
arch/powerpc/platforms/85xx/mpc85xx.h +0 -2
@@ -10,10 +10,8 @@ static inline void __init mpc85xx_cpm2_pic_init(void) {}#endif /* CONFIG_CPM2 */ #ifdef CONFIG_QUICC_ENGINE -extern void mpc85xx_qe_init (void );extern void mpc85xx_qe_par_io_init (void );#else -static inline void __init mpc85xx_qe_init (void ) {}static inline void __init mpc85xx_qe_par_io_init (void ) {}#endif
arch/powerpc/platforms/85xx/mpc85xx_mds.c +0 -1
@@ -237,7 +237,6 @@ static void __init mpc85xx_mds_qe_init(void) {struct device_node *np; -mpc85xx_qe_init ();mpc85xx_qe_par_io_init ();mpc85xx_mds_reset_ucc_phys ();
arch/powerpc/platforms/85xx/mpc85xx_rdb.c +0 -1
@@ -72,7 +72,6 @@ static void __init mpc85xx_rdb_setup_arch(void)fsl_pci_assign_primary (); #ifdef CONFIG_QUICC_ENGINE - mpc85xx_qe_init(); mpc85xx_qe_par_io_init(); #if defined(CONFIG_UCC_GETH) || defined(CONFIG_SERIAL_QE) if (machine_is(p1025_rdb)) {
arch/powerpc/platforms/85xx/twr_p102x.c +0 -1
@@ -57,7 +57,6 @@ static void __init twr_p1025_setup_arch(void)fsl_pci_assign_primary ();#ifdef CONFIG_QUICC_ENGINE -mpc85xx_qe_init ();mpc85xx_qe_par_io_init ();#if IS_ENABLED (CONFIG_UCC_GETH ) ||IS_ENABLED (CONFIG_SERIAL_QE )
Signature · 1 line
2.23.0
PATCH v4 15/47 soc: fsl: qe: move qe_ic_cascade_* functions to qe_ic.c
In reply to Rasmus VillemoesThese functions are only ever called through a function pointer, and therefore it makes no sense for them to be "static inline" - gcc has no choice but to emit a copy in each translation unit that takes the address of one of these. Since they are now only referenced from qe_ic.c, just make them local to that file.
--- drivers/soc/fsl/qe/qe_ic.c | 42 ++++++++++++++++++++++++++++++++++++++ include/soc/fsl/qe/qe_ic.h | 42 -------------------------------------- 2 files changed, 42 insertions(+), 42 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +42 -0
@@ -314,6 +314,48 @@ unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)return irq_linear_revmap (qe_ic->irqhost, irq); } +static void qe_ic_cascade_low_mpic (struct irq_desc *desc) +{ +struct qe_ic *qe_ic =irq_desc_get_handler_data (desc); +unsigned int cascade_irq =qe_ic_get_low_irq (qe_ic); +struct irq_chip *chip =irq_desc_get_chip (desc); + +if (cascade_irq !=NO_IRQ ) +generic_handle_irq (cascade_irq); + +if (chip->irq_eoi) + chip->irq_eoi (&desc->irq_data); +} + +static void qe_ic_cascade_high_mpic (struct irq_desc *desc) +{ +struct qe_ic *qe_ic =irq_desc_get_handler_data (desc); +unsigned int cascade_irq =qe_ic_get_high_irq (qe_ic); +struct irq_chip *chip =irq_desc_get_chip (desc); + +if (cascade_irq !=NO_IRQ ) +generic_handle_irq (cascade_irq); + +if (chip->irq_eoi) + chip->irq_eoi (&desc->irq_data); +} + +static void qe_ic_cascade_muxed_mpic (struct irq_desc *desc) +{ +struct qe_ic *qe_ic =irq_desc_get_handler_data (desc); +unsigned int cascade_irq; +struct irq_chip *chip =irq_desc_get_chip (desc); + + cascade_irq =qe_ic_get_high_irq (qe_ic); +if (cascade_irq ==NO_IRQ ) + cascade_irq =qe_ic_get_low_irq (qe_ic); + +if (cascade_irq !=NO_IRQ ) +generic_handle_irq (cascade_irq); + + chip->irq_eoi (&desc->irq_data); +} +static void __init qe_ic_init (struct device_node *node,unsigned int flags) {void (*low_handler)(struct irq_desc *desc);
include/soc/fsl/qe/qe_ic.h +0 -42
46 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH v4 16/47 soc: fsl: qe: rename qe_ic_cascade_low_mpic -> qe_ic_cascade_low
In reply to Rasmus VillemoesThe qe_ic_cascade_{low,high}_mpic functions are now used as handlers both when the interrupt parent is mpic as well as ipic, so remove the _mpic suffix.
--- drivers/soc/fsl/qe/qe_ic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +4 -4
@@ -314,7 +314,7 @@ unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)return irq_linear_revmap (qe_ic->irqhost, irq); } -static void qe_ic_cascade_low_mpic (struct irq_desc *desc) +static void qe_ic_cascade_low (struct irq_desc *desc) {struct qe_ic *qe_ic =irq_desc_get_handler_data (desc);unsigned int cascade_irq =qe_ic_get_low_irq (qe_ic);
@@ -327,7 +327,7 @@ static void qe_ic_cascade_low_mpic(struct irq_desc *desc) chip->irq_eoi (&desc->irq_data); } -static void qe_ic_cascade_high_mpic (struct irq_desc *desc) +static void qe_ic_cascade_high (struct irq_desc *desc) {struct qe_ic *qe_ic =irq_desc_get_handler_data (desc);unsigned int cascade_irq =qe_ic_get_high_irq (qe_ic);
@@ -392,8 +392,8 @@ static void __init qe_ic_init(struct device_node *node, unsigned int flags)return ; }if (qe_ic->virq_high != qe_ic->virq_low) { - low_handler = qe_ic_cascade_low_mpic; - high_handler = qe_ic_cascade_high_mpic; + low_handler = qe_ic_cascade_low; + high_handler = qe_ic_cascade_high; }else { low_handler = qe_ic_cascade_muxed_mpic; high_handler =NULL ;
Signature · 1 line
2.23.0
PATCH v4 17/47 soc: fsl: qe: remove unused qe_ic_set_* functions
In reply to Rasmus VillemoesThere are no current callers of these functions, and they use the ppc-specific virq_to_hw(). So removing them gets us one step closer to building QE support for ARM.
If the functionality is ever actually needed, the code can be dug out of git and then adapted to work on all architectures, but for future reference please note that I believe qe_ic_set_priority is buggy: The "priority < 4" should be "priority <= 4", and in the else branch 24 should be replaced by 28, at least if I'm reading the data sheet right.
--- drivers/soc/fsl/qe/qe_ic.c | 94 -------------------------------------- include/soc/fsl/qe/qe_ic.h | 4 -- 2 files changed, 98 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +0 -94
@@ -445,97 +445,3 @@ static int __init qe_ic_of_init(void)return 0 ; }subsys_initcall (qe_ic_of_init); - -void qe_ic_set_highest_priority (unsigned int virq,int high) -{ -struct qe_ic *qe_ic =qe_ic_from_irq (virq); -unsigned int src =virq_to_hw (virq); -u32 temp =0 ; - - temp =qe_ic_read (qe_ic->regs,QEIC_CICR ); - - temp &= ~CICR_HP_MASK ; - temp |= src <<CICR_HP_SHIFT ; - - temp &= ~CICR_HPIT_MASK ; - temp |= (high ?SIGNAL_HIGH :SIGNAL_LOW ) <<CICR_HPIT_SHIFT ; - -qe_ic_write (qe_ic->regs,QEIC_CICR , temp); -} - -/* Set Priority level within its group, from 1 to 8 */ -int qe_ic_set_priority (unsigned int virq,unsigned int priority) -{ -struct qe_ic *qe_ic =qe_ic_from_irq (virq); -unsigned int src =virq_to_hw (virq); -u32 temp; - -if (priority >8 || priority ==0 ) -return -EINVAL ; -if (WARN_ONCE (src >=ARRAY_SIZE (qe_ic_info), -"%s: Invalid hw irq number for QEIC\n" , __func__)) -return -EINVAL ; -if (qe_ic_info[src].pri_reg ==0 ) -return -EINVAL ; - - temp =qe_ic_read (qe_ic->regs, qe_ic_info[src].pri_reg); - -if (priority <4 ) { - temp &= ~(0x7 << (32 - priority *3 )); - temp |= qe_ic_info[src].pri_code << (32 - priority *3 ); - }else { - temp &= ~(0x7 << (24 - priority *3 )); - temp |= qe_ic_info[src].pri_code << (24 - priority *3 ); - } - -qe_ic_write (qe_ic->regs, qe_ic_info[src].pri_reg, temp); - -return 0 ; -} - -/* Set a QE priority to use high irq, only priority 1~2 can use high irq */ -int qe_ic_set_high_priority (unsigned int virq,unsigned int priority,int high) -{ -struct qe_ic *qe_ic =qe_ic_from_irq (virq); -unsigned int src =virq_to_hw (virq); -u32 temp, control_reg =QEIC_CICNR , shift =0 ; - -if (priority >2 || priority ==0 ) -return -EINVAL ; -if (WARN_ONCE (src >=ARRAY_SIZE (qe_ic_info), -"%s: Invalid hw irq number for QEIC\n" , __func__)) -return -EINVAL ; - -switch (qe_ic_info[src].pri_reg) { -case QEIC_CIPZCC : - shift =CICNR_ZCC1T_SHIFT ; -break ; -case QEIC_CIPWCC : - shift =CICNR_WCC1T_SHIFT ; -break ; -case QEIC_CIPYCC : - shift =CICNR_YCC1T_SHIFT ; -break ; -case QEIC_CIPXCC : - shift =CICNR_XCC1T_SHIFT ; -break ; -case QEIC_CIPRTA : - shift =CRICR_RTA1T_SHIFT ; - control_reg =QEIC_CRICR ; -break ; -case QEIC_CIPRTB : - shift =CRICR_RTB1T_SHIFT ; - control_reg =QEIC_CRICR ; -break ; -default : -return -EINVAL ; - } - - shift += (2 - priority) *2 ; - temp =qe_ic_read (qe_ic->regs, control_reg); - temp &= ~(SIGNAL_MASK << shift); - temp |= (high ?SIGNAL_HIGH :SIGNAL_LOW ) << shift; -qe_ic_write (qe_ic->regs, control_reg, temp); - -return 0 ; -}
include/soc/fsl/qe/qe_ic.h +0 -4
@@ -63,8 +63,4 @@ static inline unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic) {return 0 ; }#endif /* CONFIG_QUICC_ENGINE */ -void qe_ic_set_highest_priority (unsigned int virq,int high); -int qe_ic_set_priority (unsigned int virq,unsigned int priority); -int qe_ic_set_high_priority (unsigned int virq,unsigned int priority,int high); -#endif /* _ASM_POWERPC_QE_IC_H */
Signature · 1 line
2.23.0
PATCH v4 18/47 soc: fsl: qe: don't use NO_IRQ in qe_ic.c
In reply to Rasmus VillemoesThis driver is currently PPC-only, and on powerpc, NO_IRQ is 0, so this doesn't change functionality. However, not every architecture defines NO_IRQ, and some define it as -1, so the detection of a failed irq_of_parse_and_map() (which returns 0 on failure) would be wrong on those. So to prepare for allowing this driver to build on other architectures, drop all references to NO_IRQ.
--- drivers/soc/fsl/qe/qe_ic.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +10 -11
@@ -282,7 +282,7 @@ static const struct irq_domain_ops qe_ic_host_ops = { .xlate = irq_domain_xlate_onetwocell, }; -/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */ +/* Return an interrupt vector or 0 if no interrupt is pending. */ unsigned int qe_ic_get_low_irq (struct qe_ic *qe_ic) {int irq;
@@ -293,12 +293,12 @@ unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic) irq =qe_ic_read (qe_ic->regs,QEIC_CIVEC ) >>26 ;if (irq ==0 ) -return NO_IRQ ; +return 0 ;return irq_linear_revmap (qe_ic->irqhost, irq); } -/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */ +/* Return an interrupt vector or 0 if no interrupt is pending. */ unsigned int qe_ic_get_high_irq (struct qe_ic *qe_ic) {int irq;
@@ -309,7 +309,7 @@ unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic) irq =qe_ic_read (qe_ic->regs,QEIC_CHIVEC ) >>26 ;if (irq ==0 ) -return NO_IRQ ; +return 0 ;return irq_linear_revmap (qe_ic->irqhost, irq); }
@@ -320,7 +320,7 @@ static void qe_ic_cascade_low(struct irq_desc *desc)unsigned int cascade_irq =qe_ic_get_low_irq (qe_ic);struct irq_chip *chip =irq_desc_get_chip (desc); -if (cascade_irq !=NO_IRQ ) +if (cascade_irq !=0 )generic_handle_irq (cascade_irq);if (chip->irq_eoi)
@@ -333,7 +333,7 @@ static void qe_ic_cascade_high(struct irq_desc *desc)unsigned int cascade_irq =qe_ic_get_high_irq (qe_ic);struct irq_chip *chip =irq_desc_get_chip (desc); -if (cascade_irq !=NO_IRQ ) +if (cascade_irq !=0 )generic_handle_irq (cascade_irq);if (chip->irq_eoi)
@@ -347,10 +347,10 @@ static void qe_ic_cascade_muxed_mpic(struct irq_desc *desc)struct irq_chip *chip =irq_desc_get_chip (desc); cascade_irq =qe_ic_get_high_irq (qe_ic); -if (cascade_irq ==NO_IRQ ) +if (cascade_irq ==0 ) cascade_irq =qe_ic_get_low_irq (qe_ic); -if (cascade_irq !=NO_IRQ ) +if (cascade_irq !=0 )generic_handle_irq (cascade_irq); chip->irq_eoi (&desc->irq_data);
@@ -386,7 +386,7 @@ static void __init qe_ic_init(struct device_node *node, unsigned int flags) qe_ic->virq_high =irq_of_parse_and_map (node,0 ); qe_ic->virq_low =irq_of_parse_and_map (node,1 ); -if (qe_ic->virq_low ==NO_IRQ ) { +if (!qe_ic->virq_low) {printk (KERN_ERR "Failed to map QE_IC low IRQ\n" );kfree (qe_ic);return ;
@@ -423,8 +423,7 @@ static void __init qe_ic_init(struct device_node *node, unsigned int flags)irq_set_handler_data (qe_ic->virq_low, qe_ic);irq_set_chained_handler (qe_ic->virq_low, low_handler); -if (qe_ic->virq_high !=NO_IRQ && - qe_ic->virq_high != qe_ic->virq_low) { +if (qe_ic->virq_high && qe_ic->virq_high != qe_ic->virq_low) {irq_set_handler_data (qe_ic->virq_high, qe_ic);irq_set_chained_handler (qe_ic->virq_high, high_handler); }
Signature · 1 line
2.23.0
PATCH v4 19/47 soc: fsl: qe: make qe_ic_get_{low,high}_irq static
In reply to Rasmus VillemoesThese are only called from within qe_ic.c, so make them static.
--- drivers/soc/fsl/qe/qe_ic.c | 4 ++-- include/soc/fsl/qe/qe_ic.h | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +2 -2
@@ -283,7 +283,7 @@ static const struct irq_domain_ops qe_ic_host_ops = { };/* Return an interrupt vector or 0 if no interrupt is pending. */ -unsigned int qe_ic_get_low_irq (struct qe_ic *qe_ic) +static unsigned int qe_ic_get_low_irq (struct qe_ic *qe_ic) {int irq;
@@ -299,7 +299,7 @@ unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic) }/* Return an interrupt vector or 0 if no interrupt is pending. */ -unsigned int qe_ic_get_high_irq (struct qe_ic *qe_ic) +static unsigned int qe_ic_get_high_irq (struct qe_ic *qe_ic) {int irq;
include/soc/fsl/qe/qe_ic.h +0 -10
@@ -53,14 +53,4 @@ enum qe_ic_grp_id {QE_IC_GRP_RISCB /* QE interrupt controller RISC group B */ }; -#ifdef CONFIG_QUICC_ENGINE -unsigned int qe_ic_get_low_irq (struct qe_ic *qe_ic); -unsigned int qe_ic_get_high_irq (struct qe_ic *qe_ic); -#else -static inline unsigned int qe_ic_get_low_irq (struct qe_ic *qe_ic) -{return 0 ; } -static inline unsigned int qe_ic_get_high_irq (struct qe_ic *qe_ic) -{return 0 ; } -#endif /* CONFIG_QUICC_ENGINE */ -#endif /* _ASM_POWERPC_QE_IC_H */
Signature · 1 line
2.23.0
PATCH v4 20/47 soc: fsl: qe: simplify qe_ic_init()
In reply to Rasmus Villemoesqe_ic_init() takes a flags parameter, but all callers (including the sole remaining one) have always passed 0. So remove that parameter and simplify the body accordingly. We still explicitly initialize the Interrupt Configuration Register (CICR) to its reset value of all-zeroes, just in case the bootloader has played funny games.
--- drivers/soc/fsl/qe/qe_ic.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
drivers/soc/fsl/qe/qe_ic.c +4 -23
@@ -356,13 +356,13 @@ static void qe_ic_cascade_muxed_mpic(struct irq_desc *desc) chip->irq_eoi (&desc->irq_data); } -static void __init qe_ic_init (struct device_node *node,unsigned int flags) +static void __init qe_ic_init (struct device_node *node) {void (*low_handler)(struct irq_desc *desc);void (*high_handler)(struct irq_desc *desc);struct qe_ic *qe_ic;struct resource res; -u32 temp =0 , ret; +u32 ret; ret =of_address_to_resource (node,0 , &res);if (ret)
@@ -399,26 +399,7 @@ static void __init qe_ic_init(struct device_node *node, unsigned int flags) high_handler =NULL ; } -/* default priority scheme is grouped. If spread mode is */ -/* required, configure cicr accordingly. */ -if (flags &QE_IC_SPREADMODE_GRP_W ) - temp |=CICR_GWCC ; -if (flags &QE_IC_SPREADMODE_GRP_X ) - temp |=CICR_GXCC ; -if (flags &QE_IC_SPREADMODE_GRP_Y ) - temp |=CICR_GYCC ; -if (flags &QE_IC_SPREADMODE_GRP_Z ) - temp |=CICR_GZCC ; -if (flags &QE_IC_SPREADMODE_GRP_RISCA ) - temp |=CICR_GRTA ; -if (flags &QE_IC_SPREADMODE_GRP_RISCB ) - temp |=CICR_GRTB ; - -/* choose destination signal for highest priority interrupt */ -if (flags &QE_IC_HIGH_SIGNAL ) - temp |= (SIGNAL_HIGH <<CICR_HPIT_SHIFT ); - -qe_ic_write (qe_ic->regs,QEIC_CICR , temp); +qe_ic_write (qe_ic->regs,QEIC_CICR ,0 );irq_set_handler_data (qe_ic->virq_low, qe_ic);irq_set_chained_handler (qe_ic->virq_low, low_handler);
@@ -439,7 +420,7 @@ static int __init qe_ic_of_init(void)if (!np)return -ENODEV ; } -qe_ic_init (np,0 ); +qe_ic_init (np);of_node_put (np);return 0 ; }
Signature · 1 line
2.23.0
PATCH v4 21/47 soc: fsl: qe: merge qe_ic.h headers into qe_ic.c
In reply to Rasmus VillemoesThe public qe_ic.h header is no longer included by anything but qe_ic.c. Merge both headers into qe_ic.c, and drop the unused constants.
--- drivers/soc/fsl/qe/qe_ic.c | 52 +++++++++++++++++++- drivers/soc/fsl/qe/qe_ic.h | 99 -------------------------------------- include/soc/fsl/qe/qe_ic.h | 56 --------------------- 3 files changed, 50 insertions(+), 157 deletions(-) delete mode 100644 drivers/soc/fsl/qe/qe_ic.h delete mode 100644 include/soc/fsl/qe/qe_ic.h
drivers/soc/fsl/qe/qe_ic.c +50 -2
@@ -15,6 +15,7 @@#include <linux/kernel.h> #include <linux/init.h> #include <linux/errno.h> +#include <linux/irq.h> #include <linux/reboot.h> #include <linux/slab.h> #include <linux/stddef.h>
@@ -25,9 +26,56 @@#include <asm/irq.h> #include <asm/io.h> #include <soc/fsl/qe/qe.h> -#include <soc/fsl/qe/qe_ic.h> -#include "qe_ic.h" +#define NR_QE_IC_INTS 64 + +/* QE IC registers offset */ +#define QEIC_CICR 0x00 +#define QEIC_CIVEC 0x04 +#define QEIC_CIPXCC 0x10 +#define QEIC_CIPYCC 0x14 +#define QEIC_CIPWCC 0x18 +#define QEIC_CIPZCC 0x1c +#define QEIC_CIMR 0x20 +#define QEIC_CRIMR 0x24 +#define QEIC_CIPRTA 0x30 +#define QEIC_CIPRTB 0x34 +#define QEIC_CHIVEC 0x60 + +struct qe_ic { +/* Control registers offset */ +u32 __iomem *regs; + +/* The remapper for this QEIC */ +struct irq_domain *irqhost; + +/* The "linux" controller struct */ +struct irq_chip hc_irq; + +/* VIRQ numbers of QE high/low irqs */ +unsigned int virq_high; +unsigned int virq_low; +}; + +/* +* QE interrupt controller internal structure +*/ +struct qe_ic_info { +/* Location of this source at the QIMR register */ +u32 mask; + +/* Mask register offset */ +u32 mask_reg; + +/* +* For grouped interrupts sources - the interrupt code as +* appears at the group priority register +*/ +u8 pri_code; + +/* Group priority register offset */ +u32 pri_reg; +};static DEFINE_RAW_SPINLOCK (qe_ic_lock);
drivers/soc/fsl/qe/qe_ic.h deleted +0 -99
99 lines not on this page · raw message
include/soc/fsl/qe/qe_ic.h deleted +0 -56
56 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH v4 22/47 soc: fsl: qe: qe.c: use of_property_read_* helpers
In reply to Rasmus VillemoesInstead of manually doing of_get_property/of_find_property and reading the value by assigning to a u32* or u64* and dereferencing, use the of_property_read_* functions.
This make the code more readable, and more importantly, is required for this to work correctly on little-endian platforms.
--- drivers/soc/fsl/qe/qe.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-)
drivers/soc/fsl/qe/qe.c +8 -25
@@ -159,8 +159,7 @@ static unsigned int brg_clk = 0;unsigned int qe_get_brg_clk (void ) {struct device_node *qe; -int size; -const u32 *prop; +u32 brg;unsigned int mod;if (brg_clk)
@@ -170,9 +169,8 @@ unsigned int qe_get_brg_clk(void)if (!qe)return brg_clk; - prop =of_get_property (qe,"brg-frequency" , &size); -if (prop && size ==sizeof (*prop)) - brg_clk = *prop; +if (!of_property_read_u32 (qe,"brg-frequency" , &brg)) + brg_clk = brg;of_node_put (qe);
@@ -571,11 +569,9 @@ EXPORT_SYMBOL(qe_upload_firmware);struct qe_firmware_info *qe_get_firmware_info (void ) {static int initialized; -struct property *prop;struct device_node *qe;struct device_node *fw =NULL ;const char *sprop; -unsigned int i;/* * If we haven't checked yet, and a driver hasn't uploaded a firmware
@@ -609,20 +605,11 @@ struct qe_firmware_info *qe_get_firmware_info(void)strlcpy (qe_firmware_info.id, sprop,sizeof (qe_firmware_info.id)); - prop =of_find_property (fw,"extended-modes" ,NULL ); -if (prop && (prop->length ==sizeof (u64))) { -const u64 *iprop = prop->value; - - qe_firmware_info.extended_modes = *iprop; - } +of_property_read_u64 (fw,"extended-modes" , + &qe_firmware_info.extended_modes); - prop =of_find_property (fw,"virtual-traps" ,NULL ); -if (prop && (prop->length ==32 )) { -const u32 *iprop = prop->value; - -for (i =0 ; i <ARRAY_SIZE (qe_firmware_info.vtraps); i++) - qe_firmware_info.vtraps[i] = iprop[i]; - } +of_property_read_u32_array (fw,"virtual-traps" , qe_firmware_info.vtraps, +ARRAY_SIZE (qe_firmware_info.vtraps));of_node_put (fw);
@@ -633,17 +620,13 @@ EXPORT_SYMBOL(qe_get_firmware_info);unsigned int qe_get_num_of_risc (void ) {struct device_node *qe; -int size;unsigned int num_of_risc =0 ; -const u32 *prop; qe =qe_get_device_node ();if (!qe)return num_of_risc; - prop =of_get_property (qe,"fsl,qe-num-riscs" , &size); -if (prop && size ==sizeof (*prop)) - num_of_risc = *prop; +of_property_read_u32 (qe,"fsl,qe-num-riscs" , &num_of_risc);of_node_put (qe);
Signature · 1 line
2.23.0
PATCH v4 23/47 soc: fsl: qe: qe_io.c: don't open-code of_parse_phandle()
In reply to Rasmus Villemoes--- drivers/soc/fsl/qe/qe_io.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/soc/fsl/qe/qe_io.c +2 -5
@@ -141,7 +141,6 @@ EXPORT_SYMBOL(par_io_data_set);int par_io_of_config (struct device_node *np) {struct device_node *pio; -const phandle *ph;int pio_map_len;const unsigned int *pio_map;
@@ -150,14 +149,12 @@ int par_io_of_config(struct device_node *np)return -1 ; } - ph =of_get_property (np,"pio-handle" ,NULL ); -if (ph ==NULL ) { + pio =of_parse_phandle (np,"pio-handle" ,0 ); +if (pio ==NULL ) {printk (KERN_ERR "pio-handle not available\n" );return -1 ; } - pio =of_find_node_by_phandle (*ph); - pio_map =of_get_property (pio,"pio-map" , &pio_map_len);if (pio_map ==NULL ) {printk (KERN_ERR "pio-map is not set!\n" );
Signature · 1 line
2.23.0
PATCH v4 24/47 soc: fsl: qe: qe_io.c: access device tree property using be32_to_cpu
In reply to Rasmus VillemoesWe need to apply be32_to_cpu to make this work correctly on little-endian hosts.
--- drivers/soc/fsl/qe/qe_io.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/soc/fsl/qe/qe_io.c +10 -4
@@ -142,7 +142,7 @@ int par_io_of_config(struct device_node *np) {struct device_node *pio;int pio_map_len; -const unsigned int *pio_map; +const __be32 *pio_map;if (par_io ==NULL ) {printk (KERN_ERR "par_io not initialized\n" );
@@ -167,9 +167,15 @@ int par_io_of_config(struct device_node *np) }while (pio_map_len >0 ) { -par_io_config_pin ((u8 ) pio_map[0 ], (u8 ) pio_map[1 ], - (int ) pio_map[2 ], (int ) pio_map[3 ], - (int ) pio_map[4 ], (int ) pio_map[5 ]); +u8 port =be32_to_cpu (pio_map[0 ]); +u8 pin =be32_to_cpu (pio_map[1 ]); +int dir =be32_to_cpu (pio_map[2 ]); +int open_drain =be32_to_cpu (pio_map[3 ]); +int assignment =be32_to_cpu (pio_map[4 ]); +int has_irq =be32_to_cpu (pio_map[5 ]); + +par_io_config_pin (port, pin, dir, open_drain, + assignment, has_irq); pio_map +=6 ; pio_map_len -=6 ; }
Signature · 1 line
2.23.0
PATCH v4 25/47 soc: fsl: qe: qe_io.c: use of_property_read_u32() in par_io_init()
In reply to Rasmus VillemoesThis is necessary for this to work on little-endian hosts.
--- drivers/soc/fsl/qe/qe_io.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/soc/fsl/qe/qe_io.c +3 -4
@@ -28,7 +28,7 @@ int par_io_init(struct device_node *np) {struct resource res;int ret; -const u32 *num_ports; +u32 num_ports;/* Map Parallel I/O ports registers */ ret =of_address_to_resource (np,0 , &res);
@@ -36,9 +36,8 @@ int par_io_init(struct device_node *np)return ret; par_io =ioremap (res.start,resource_size (&res)); - num_ports =of_get_property (np,"num-ports" ,NULL ); -if (num_ports) - num_par_io_ports = *num_ports; +if (!of_property_read_u32 (np,"num-ports" , &num_ports)) + num_par_io_ports = num_ports;return 0 ; }
Signature · 1 line
2.23.0
PATCH v4 26/47 soc: fsl: move cpm.h from powerpc/include/asm to include/soc/fsl
In reply to Rasmus VillemoesSome drivers, e.g. ucc_uart, need definitions from cpm.h. In order to allow building those drivers for non-ppc based SOCs, move the header to include/soc/fsl. For now, leave a trivial wrapper at the old location so drivers can be updated one by one.
--- arch/powerpc/include/asm/cpm.h | 172 +-------------------------------- include/soc/fsl/cpm.h | 171 ++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 171 deletions(-) create mode 100644 include/soc/fsl/cpm.h
arch/powerpc/include/asm/cpm.h +1 -171
@@ -1,171 +1 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __CPM_H -#define __CPM_H - -#include <linux/compiler.h> -#include <linux/types.h> -#include <linux/errno.h> -#include <linux/of.h> -#include <soc/fsl/qe/qe.h> - -/* -* SPI Parameter RAM common to QE and CPM. -*/ -struct spi_pram { -__be16 rbase;/* Rx Buffer descriptor base address */ -__be16 tbase;/* Tx Buffer descriptor base address */ -u8 rfcr;/* Rx function code */ -u8 tfcr;/* Tx function code */ -__be16 mrblr;/* Max receive buffer length */ -__be32 rstate;/* Internal */ -__be32 rdp;/* Internal */ -__be16 rbptr;/* Internal */ -__be16 rbc;/* Internal */ -__be32 rxtmp;/* Internal */ -__be32 tstate;/* Internal */ -__be32 tdp;/* Internal */ -__be16 tbptr;/* Internal */ -__be16 tbc;/* Internal */ -__be32 txtmp;/* Internal */ -__be32 res;/* Tx temp. */ -__be16 rpbase;/* Relocation pointer (CPM1 only) */ -__be16 res1;/* Reserved */ -}; - -/* -* USB Controller pram common to QE and CPM. -*/ -struct usb_ctlr { -u8 usb_usmod; -u8 usb_usadr; -u8 usb_uscom; -u8 res1[1 ]; -__be16 usb_usep[4 ]; -u8 res2[4 ]; -__be16 usb_usber; -u8 res3[2 ]; -__be16 usb_usbmr; -u8 res4[1 ]; -u8 usb_usbs; -/* Fields down below are QE-only */ -__be16 usb_ussft; -u8 res5[2 ]; -__be16 usb_usfrn; -u8 res6[0x22 ]; -} __attribute__ ((packed)); - -/* -* Function code bits, usually generic to devices. -*/ -#ifdef CONFIG_CPM1 -#define CPMFCR_GBL ((u_char)0x00)/* Flag doesn't exist in CPM1 */ -#define CPMFCR_TC2 ((u_char)0x00)/* Flag doesn't exist in CPM1 */ -#define CPMFCR_DTB ((u_char)0x00)/* Flag doesn't exist in CPM1 */ -#define CPMFCR_BDB ((u_char)0x00)/* Flag doesn't exist in CPM1 */ -#else -#define CPMFCR_GBL ((u_char)0x20)/* Set memory snooping */ -#define CPMFCR_TC2 ((u_char)0x04)/* Transfer code 2 value */ -#define CPMFCR_DTB ((u_char)0x02)/* Use local bus for data when set */ -#define CPMFCR_BDB ((u_char)0x01)/* Use local bus for BD when set */ -#endif -#define CPMFCR_EB ((u_char)0x10)/* Set big endian byte order */ - -/* Opcodes common to CPM1 and CPM2 -*/ -#define CPM_CR_INIT_TRX ((ushort)0x0000) -#define CPM_CR_INIT_RX ((ushort)0x0001) -#define CPM_CR_INIT_TX ((ushort)0x0002) -#define CPM_CR_HUNT_MODE ((ushort)0x0003) -#define CPM_CR_STOP_TX ((ushort)0x0004) -#define CPM_CR_GRA_STOP_TX ((ushort)0x0005) -#define CPM_CR_RESTART_TX ((ushort)0x0006) -#define CPM_CR_CLOSE_RX_BD ((ushort)0x0007) -#define CPM_CR_SET_GADDR ((ushort)0x0008) -#define CPM_CR_SET_TIMER ((ushort)0x0008) -#define CPM_CR_STOP_IDMA ((ushort)0x000b) - -/* Buffer descriptors used by many of the CPM protocols. */ -typedef struct cpm_buf_desc { -ushort cbd_sc;/* Status and Control */ -ushort cbd_datlen;/* Data length in buffer */ -uint cbd_bufaddr;/* Buffer address in host memory */ -}cbd_t ; - -/* Buffer descriptor control/status used by serial -*/ - -#define BD_SC_EMPTY (0x8000)/* Receive is empty */ -#define BD_SC_READY (0x8000)/* Transmit is ready */ -#define BD_SC_WRAP (0x2000)/* Last buffer descriptor */ -#define BD_SC_INTRPT (0x1000)/* Interrupt on change */ -#define BD_SC_LAST (0x0800)/* Last buffer in frame */ -#define BD_SC_TC (0x0400)/* Transmit CRC */ -#define BD_SC_CM (0x0200)/* Continuous mode */ -#define BD_SC_ID (0x0100)/* Rec'd too many idles */ -#define BD_SC_P (0x0100)/* xmt preamble */ -#define BD_SC_BR (0x0020)/* Break received */ -#define BD_SC_FR (0x0010)/* Framing error */ -#define BD_SC_PR (0x0008)/* Parity error */ -#define BD_SC_NAK (0x0004)/* NAK - did not respond */ -#define BD_SC_OV (0x0002)/* Overrun */ -#define BD_SC_UN (0x0002)/* Underrun */ -#define BD_SC_CD (0x0001)/* */ -#define BD_SC_CL (0x0001)/* Collision */ - -/* Buffer descriptor control/status used by Ethernet receive. -* Common to SCC and FCC. -*/ -#define BD_ENET_RX_EMPTY (0x8000) -#define BD_ENET_RX_WRAP (0x2000) -#define BD_ENET_RX_INTR (0x1000) -#define BD_ENET_RX_LAST (0x0800) -#define BD_ENET_RX_FIRST (0x0400) -#define BD_ENET_RX_MISS (0x0100) -#define BD_ENET_RX_BC (0x0080)/* FCC Only */ -#define BD_ENET_RX_MC (0x0040)/* FCC Only */ -#define BD_ENET_RX_LG (0x0020) -#define BD_ENET_RX_NO (0x0010) -#define BD_ENET_RX_SH (0x0008) -#define BD_ENET_RX_CR (0x0004) -#define BD_ENET_RX_OV (0x0002) -#define BD_ENET_RX_CL (0x0001) -#define BD_ENET_RX_STATS (0x01ff)/* All status bits */ - -/* Buffer descriptor control/status used by Ethernet transmit. -* Common to SCC and FCC. -*/ -#define BD_ENET_TX_READY (0x8000) -#define BD_ENET_TX_PAD (0x4000) -#define BD_ENET_TX_WRAP (0x2000) -#define BD_ENET_TX_INTR (0x1000) -#define BD_ENET_TX_LAST (0x0800) -#define BD_ENET_TX_TC (0x0400) -#define BD_ENET_TX_DEF (0x0200) -#define BD_ENET_TX_HB (0x0100) -#define BD_ENET_TX_LC (0x0080) -#define BD_ENET_TX_RL (0x0040) -#define BD_ENET_TX_RCMASK (0x003c) -#define BD_ENET_TX_UN (0x0002) -#define BD_ENET_TX_CSL (0x0001) -#define BD_ENET_TX_STATS (0x03ff)/* All status bits */ - -/* Buffer descriptor control/status used by Transparent mode SCC. -*/ -#define BD_SCC_TX_LAST (0x0800) - -/* Buffer descriptor control/status used by I2C. -*/ -#define BD_I2C_START (0x0400) - -#ifdef CONFIG_CPM -int cpm_command (u32 command,u8 opcode); -#else -static inline int cpm_command (u32 command,u8 opcode) -{ -return -ENOSYS ; -} -#endif /* CONFIG_CPM */ - -int cpm2_gpiochip_add32 (struct device *dev); - -#endif +#include <soc/fsl/cpm.h>
include/soc/fsl/cpm.h new file +171 -0
171 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH v4 27/47 soc/fsl/qe/qe.h: update include path for cpm.h
In reply to Rasmus Villemoesasm/cpm.h under arch/powerpc is now just a wrapper for including soc/fsl/cpm.h. In order to make the qe.h header usable on other architectures, use the latter path directly.
--- include/soc/fsl/qe/qe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/soc/fsl/qe/qe.h +1 -1
@@ -17,7 +17,7 @@#include <linux/spinlock.h> #include <linux/errno.h> #include <linux/err.h> -#include <asm/cpm.h> +#include <soc/fsl/cpm.h> #include <soc/fsl/qe/immap_qe.h> #include <linux/of.h> #include <linux/of_address.h>
Signature · 1 line
2.23.0
PATCH v4 28/47 serial: ucc_uart: explicitly include soc/fsl/cpm.h
In reply to Rasmus VillemoesThis driver uses #defines from soc/fsl/cpm.h, so instead of relying on some other header pulling that in, do that explicitly. This is preparation for allowing this driver to build on ARM.
--- drivers/tty/serial/ucc_uart.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/ucc_uart.c +1 -0
@@ -32,6 +32,7 @@#include <soc/fsl/qe/ucc_slow.h> #include <linux/firmware.h> +#include <soc/fsl/cpm.h> #include <asm/reg.h> /*
Signature · 1 line
2.23.0
PATCH v4 29/47 serial: ucc_uart: replace ppc-specific IO accessors
In reply to Rasmus VillemoesSome ARM-based SOCs (e.g. LS1021A) also have a QUICC engine. As preparation for allowing this driver to build on ARM, replace the ppc-specific in_be16() etc. by the qe_io* helpers. Done via coccinelle.
--- drivers/tty/serial/ucc_uart.c | 210 +++++++++++++++++----------------- 1 file changed, 102 insertions(+), 108 deletions(-)
drivers/tty/serial/ucc_uart.c +102 -108
@@ -258,11 +258,11 @@ static unsigned int qe_uart_tx_empty(struct uart_port *port)struct qe_bd *bdp = qe_port->tx_bd_base;while (1 ) { -if (in_be16 (&bdp->status) &BD_SC_READY ) +if (qe_ioread16be (&bdp->status) &BD_SC_READY )/* This BD is not done, so return "not done" */ return 0 ; -if (in_be16 (&bdp->status) &BD_SC_WRAP ) +if (qe_ioread16be (&bdp->status) &BD_SC_WRAP )/* * This BD is done and it's the last one, so return * "done"
@@ -308,7 +308,7 @@ static void qe_uart_stop_tx(struct uart_port *port)struct uart_qe_port *qe_port = container_of(port, struct uart_qe_port, port); -clrbits16 (&qe_port->uccp->uccm,UCC_UART_UCCE_TX ); +qe_clrbits_be16 (&qe_port->uccp->uccm,UCC_UART_UCCE_TX ); }/*
@@ -343,10 +343,10 @@ static int qe_uart_tx_pump(struct uart_qe_port *qe_port) p =qe2cpu_addr (bdp->buf, qe_port); *p++ = port->x_char; -out_be16 (&bdp->length,1 ); -setbits16 (&bdp->status,BD_SC_READY ); +qe_iowrite16be (1 , &bdp->length); +qe_setbits_be16 (&bdp->status,BD_SC_READY );/* Get next BD. */ -if (in_be16 (&bdp->status) &BD_SC_WRAP ) +if (qe_ioread16be (&bdp->status) &BD_SC_WRAP ) bdp = qe_port->tx_bd_base;else bdp++;
@@ -365,7 +365,7 @@ static int qe_uart_tx_pump(struct uart_qe_port *qe_port)/* Pick next descriptor and fill from buffer */ bdp = qe_port->tx_cur; -while (!(in_be16 (&bdp->status) &BD_SC_READY ) && +while (!(qe_ioread16be (&bdp->status) &BD_SC_READY ) && (xmit->tail != xmit->head)) { count =0 ; p =qe2cpu_addr (bdp->buf, qe_port);
@@ -378,11 +378,11 @@ static int qe_uart_tx_pump(struct uart_qe_port *qe_port)break ; } -out_be16 (&bdp->length, count); -setbits16 (&bdp->status,BD_SC_READY ); +qe_iowrite16be (count, &bdp->length); +qe_setbits_be16 (&bdp->status,BD_SC_READY );/* Get next BD. */ -if (in_be16 (&bdp->status) &BD_SC_WRAP ) +if (qe_ioread16be (&bdp->status) &BD_SC_WRAP ) bdp = qe_port->tx_bd_base;else bdp++;
@@ -415,12 +415,12 @@ static void qe_uart_start_tx(struct uart_port *port) container_of(port, struct uart_qe_port, port);/* If we currently are transmitting, then just return */ -if (in_be16 (&qe_port->uccp->uccm) &UCC_UART_UCCE_TX ) +if (qe_ioread16be (&qe_port->uccp->uccm) &UCC_UART_UCCE_TX )return ;/* Otherwise, pump the port and start transmission */ if (qe_uart_tx_pump (qe_port)) -setbits16 (&qe_port->uccp->uccm,UCC_UART_UCCE_TX ); +qe_setbits_be16 (&qe_port->uccp->uccm,UCC_UART_UCCE_TX ); }/*
@@ -431,7 +431,7 @@ static void qe_uart_stop_rx(struct uart_port *port)struct uart_qe_port *qe_port = container_of(port, struct uart_qe_port, port); -clrbits16 (&qe_port->uccp->uccm,UCC_UART_UCCE_RX ); +qe_clrbits_be16 (&qe_port->uccp->uccm,UCC_UART_UCCE_RX ); }/* Start or stop sending break signal
@@ -470,14 +470,14 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port)*/ bdp = qe_port->rx_cur;while (1 ) { - status =in_be16 (&bdp->status); + status =qe_ioread16be (&bdp->status);/* If this one is empty, then we assume we've read them all */ if (status &BD_SC_EMPTY )break ;/* get number of characters, and check space in RX buffer */ - i =in_be16 (&bdp->length); + i =qe_ioread16be (&bdp->length);/* If we don't have enough room in RX buffer for the entire BD, * then we try later, which will be the next RX interrupt.
@@ -508,9 +508,10 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port) }/* This BD is ready to be used again. Clear status. get next */ -clrsetbits_be16 (&bdp->status,BD_SC_BR |BD_SC_FR |BD_SC_PR | -BD_SC_OV |BD_SC_ID ,BD_SC_EMPTY ); -if (in_be16 (&bdp->status) &BD_SC_WRAP ) +qe_clrsetbits_be16 (&bdp->status, +BD_SC_BR |BD_SC_FR |BD_SC_PR |BD_SC_OV |BD_SC_ID , +BD_SC_EMPTY ); +if (qe_ioread16be (&bdp->status) &BD_SC_WRAP ) bdp = qe_port->rx_bd_base;else bdp++;
@@ -569,8 +570,8 @@ static irqreturn_t qe_uart_int(int irq, void *data)u16 events;/* Clear the interrupts */ - events =in_be16 (&uccp->ucce); -out_be16 (&uccp->ucce, events); + events =qe_ioread16be (&uccp->ucce); +qe_iowrite16be (events, &uccp->ucce);if (events &UCC_UART_UCCE_BRKE )uart_handle_break (&qe_port->port);
@@ -601,17 +602,17 @@ static void qe_uart_initbd(struct uart_qe_port *qe_port) bdp = qe_port->rx_bd_base; qe_port->rx_cur = qe_port->rx_bd_base;for (i =0 ; i < (qe_port->rx_nrfifos -1 ); i++) { -out_be16 (&bdp->status,BD_SC_EMPTY |BD_SC_INTRPT ); -out_be32 (&bdp->buf,cpu2qe_addr (bd_virt, qe_port)); -out_be16 (&bdp->length,0 ); +qe_iowrite16be (BD_SC_EMPTY |BD_SC_INTRPT , &bdp->status); +qe_iowrite32be (cpu2qe_addr (bd_virt, qe_port), &bdp->buf); +qe_iowrite16be (0 , &bdp->length); bd_virt += qe_port->rx_fifosize; bdp++; }/* */ -out_be16 (&bdp->status,BD_SC_WRAP |BD_SC_EMPTY |BD_SC_INTRPT ); -out_be32 (&bdp->buf,cpu2qe_addr (bd_virt, qe_port)); -out_be16 (&bdp->length,0 ); +qe_iowrite16be (BD_SC_WRAP |BD_SC_EMPTY |BD_SC_INTRPT , &bdp->status); +qe_iowrite32be (cpu2qe_addr (bd_virt, qe_port), &bdp->buf); +qe_iowrite16be (0 , &bdp->length);/* Set the physical address of the host memory * buffers in the buffer descriptors, and the
@@ -622,21 +623,21 @@ static void qe_uart_initbd(struct uart_qe_port *qe_port) qe_port->tx_cur = qe_port->tx_bd_base; bdp = qe_port->tx_bd_base;for (i =0 ; i < (qe_port->tx_nrfifos -1 ); i++) { -out_be16 (&bdp->status,BD_SC_INTRPT ); -out_be32 (&bdp->buf,cpu2qe_addr (bd_virt, qe_port)); -out_be16 (&bdp->length,0 ); +qe_iowrite16be (BD_SC_INTRPT , &bdp->status); +qe_iowrite32be (cpu2qe_addr (bd_virt, qe_port), &bdp->buf); +qe_iowrite16be (0 , &bdp->length); bd_virt += qe_port->tx_fifosize; bdp++; }/* Loopback requires the preamble bit to be set on the first TX BD */ #ifdef LOOPBACK -setbits16 (&qe_port->tx_cur->status,BD_SC_P ); +qe_setbits_be16 (&qe_port->tx_cur->status,BD_SC_P );#endif -out_be16 (&bdp->status,BD_SC_WRAP |BD_SC_INTRPT ); -out_be32 (&bdp->buf,cpu2qe_addr (bd_virt, qe_port)); -out_be16 (&bdp->length,0 ); +qe_iowrite16be (BD_SC_WRAP |BD_SC_INTRPT , &bdp->status); +qe_iowrite32be (cpu2qe_addr (bd_virt, qe_port), &bdp->buf); +qe_iowrite16be (0 , &bdp->length); }/*
@@ -658,78 +659,74 @@ static void qe_uart_init_ucc(struct uart_qe_port *qe_port)ucc_slow_disable (qe_port->us_private,COMM_DIR_RX_AND_TX );/* Program the UCC UART parameter RAM */ -out_8 (&uccup->common.rbmr,UCC_BMR_GBL |UCC_BMR_BO_BE ); -out_8 (&uccup->common.tbmr,UCC_BMR_GBL |UCC_BMR_BO_BE ); -out_be16 (&uccup->common.mrblr, qe_port->rx_fifosize); -out_be16 (&uccup->maxidl,0x10 ); -out_be16 (&uccup->brkcr,1 ); -out_be16 (&uccup->parec,0 ); -out_be16 (&uccup->frmec,0 ); -out_be16 (&uccup->nosec,0 ); -out_be16 (&uccup->brkec,0 ); -out_be16 (&uccup->uaddr[0 ],0 ); -out_be16 (&uccup->uaddr[1 ],0 ); -out_be16 (&uccup->toseq,0 ); +qe_iowrite8 (UCC_BMR_GBL |UCC_BMR_BO_BE , &uccup->common.rbmr); +qe_iowrite8 (UCC_BMR_GBL |UCC_BMR_BO_BE , &uccup->common.tbmr); +qe_iowrite16be (qe_port->rx_fifosize, &uccup->common.mrblr); +qe_iowrite16be (0x10 , &uccup->maxidl); +qe_iowrite16be (1 , &uccup->brkcr); +qe_iowrite16be (0 , &uccup->parec); +qe_iowrite16be (0 , &uccup->frmec); +qe_iowrite16be (0 , &uccup->nosec); +qe_iowrite16be (0 , &uccup->brkec); +qe_iowrite16be (0 , &uccup->uaddr[0 ]); +qe_iowrite16be (0 , &uccup->uaddr[1 ]); +qe_iowrite16be (0 , &uccup->toseq);for (i =0 ; i <8 ; i++) -out_be16 (&uccup->cchars[i],0xC000 ); -out_be16 (&uccup->rccm,0xc0ff ); +qe_iowrite16be (0xC000 , &uccup->cchars[i]); +qe_iowrite16be (0xc0ff , &uccup->rccm);/* Configure the GUMR registers for UART */ if (soft_uart) {/* Soft-UART requires a 1X multiplier for TX */ -clrsetbits_be32 (&uccp->gumr_l, -UCC_SLOW_GUMR_L_MODE_MASK |UCC_SLOW_GUMR_L_TDCR_MASK | -UCC_SLOW_GUMR_L_RDCR_MASK , -UCC_SLOW_GUMR_L_MODE_UART |UCC_SLOW_GUMR_L_TDCR_1 | -UCC_SLOW_GUMR_L_RDCR_16 ); - -clrsetbits_be32 (&uccp->gumr_h,UCC_SLOW_GUMR_H_RFW , -UCC_SLOW_GUMR_H_TRX |UCC_SLOW_GUMR_H_TTX ); +qe_clrsetbits_be32 (&uccp->gumr_l, +UCC_SLOW_GUMR_L_MODE_MASK |UCC_SLOW_GUMR_L_TDCR_MASK |UCC_SLOW_GUMR_L_RDCR_MASK , +UCC_SLOW_GUMR_L_MODE_UART |UCC_SLOW_GUMR_L_TDCR_1 |UCC_SLOW_GUMR_L_RDCR_16 ); + +qe_clrsetbits_be32 (&uccp->gumr_h,UCC_SLOW_GUMR_H_RFW , +UCC_SLOW_GUMR_H_TRX |UCC_SLOW_GUMR_H_TTX ); }else { -clrsetbits_be32 (&uccp->gumr_l, -UCC_SLOW_GUMR_L_MODE_MASK |UCC_SLOW_GUMR_L_TDCR_MASK | -UCC_SLOW_GUMR_L_RDCR_MASK , -UCC_SLOW_GUMR_L_MODE_UART |UCC_SLOW_GUMR_L_TDCR_16 | -UCC_SLOW_GUMR_L_RDCR_16 ); - -clrsetbits_be32 (&uccp->gumr_h, -UCC_SLOW_GUMR_H_TRX |UCC_SLOW_GUMR_H_TTX , -UCC_SLOW_GUMR_H_RFW ); +qe_clrsetbits_be32 (&uccp->gumr_l, +UCC_SLOW_GUMR_L_MODE_MASK |UCC_SLOW_GUMR_L_TDCR_MASK |UCC_SLOW_GUMR_L_RDCR_MASK , +UCC_SLOW_GUMR_L_MODE_UART |UCC_SLOW_GUMR_L_TDCR_16 |UCC_SLOW_GUMR_L_RDCR_16 ); + +qe_clrsetbits_be32 (&uccp->gumr_h, +UCC_SLOW_GUMR_H_TRX |UCC_SLOW_GUMR_H_TTX , +UCC_SLOW_GUMR_H_RFW ); }#ifdef LOOPBACK -clrsetbits_be32 (&uccp->gumr_l,UCC_SLOW_GUMR_L_DIAG_MASK , -UCC_SLOW_GUMR_L_DIAG_LOOP ); -clrsetbits_be32 (&uccp->gumr_h, -UCC_SLOW_GUMR_H_CTSP |UCC_SLOW_GUMR_H_RSYN , -UCC_SLOW_GUMR_H_CDS ); +qe_clrsetbits_be32 (&uccp->gumr_l,UCC_SLOW_GUMR_L_DIAG_MASK , +UCC_SLOW_GUMR_L_DIAG_LOOP ); +qe_clrsetbits_be32 (&uccp->gumr_h, +UCC_SLOW_GUMR_H_CTSP |UCC_SLOW_GUMR_H_RSYN , +UCC_SLOW_GUMR_H_CDS );#endif /* Disable rx interrupts and clear all pending events. */ -out_be16 (&uccp->uccm,0 ); -out_be16 (&uccp->ucce,0xffff ); -out_be16 (&uccp->udsr,0x7e7e ); +qe_iowrite16be (0 , &uccp->uccm); +qe_iowrite16be (0xffff , &uccp->ucce); +qe_iowrite16be (0x7e7e , &uccp->udsr);/* Initialize UPSMR */ -out_be16 (&uccp->upsmr,0 ); +qe_iowrite16be (0 , &uccp->upsmr);if (soft_uart) { -out_be16 (&uccup->supsmr,0x30 ); -out_be16 (&uccup->res92,0 ); -out_be32 (&uccup->rx_state,0 ); -out_be32 (&uccup->rx_cnt,0 ); -out_8 (&uccup->rx_bitmark,0 ); -out_8 (&uccup->rx_length,10 ); -out_be32 (&uccup->dump_ptr,0x4000 ); -out_8 (&uccup->rx_temp_dlst_qe,0 ); -out_be32 (&uccup->rx_frame_rem,0 ); -out_8 (&uccup->rx_frame_rem_size,0 ); +qe_iowrite16be (0x30 , &uccup->supsmr); +qe_iowrite16be (0 , &uccup->res92); +qe_iowrite32be (0 , &uccup->rx_state); +qe_iowrite32be (0 , &uccup->rx_cnt); +qe_iowrite8 (0 , &uccup->rx_bitmark); +qe_iowrite8 (10 , &uccup->rx_length); +qe_iowrite32be (0x4000 , &uccup->dump_ptr); +qe_iowrite8 (0 , &uccup->rx_temp_dlst_qe); +qe_iowrite32be (0 , &uccup->rx_frame_rem); +qe_iowrite8 (0 , &uccup->rx_frame_rem_size);/* Soft-UART requires TX to be 1X */ -out_8 (&uccup->tx_mode, -UCC_UART_TX_STATE_UART |UCC_UART_TX_STATE_X1 ); -out_be16 (&uccup->tx_state,0 ); -out_8 (&uccup->resD4,0 ); -out_be16 (&uccup->resD5,0 ); +qe_iowrite8 (UCC_UART_TX_STATE_UART |UCC_UART_TX_STATE_X1 , + &uccup->tx_mode); +qe_iowrite16be (0 , &uccup->tx_state); +qe_iowrite8 (0 , &uccup->resD4); +qe_iowrite16be (0 , &uccup->resD5);/* Set UART mode. * Enable receive and transmit.
@@ -743,22 +740,19 @@ static void qe_uart_init_ucc(struct uart_qe_port *qe_port)* ... * 6.Receiver must use 16x over sampling */ -clrsetbits_be32 (&uccp->gumr_l, -UCC_SLOW_GUMR_L_MODE_MASK |UCC_SLOW_GUMR_L_TDCR_MASK | -UCC_SLOW_GUMR_L_RDCR_MASK , -UCC_SLOW_GUMR_L_MODE_QMC |UCC_SLOW_GUMR_L_TDCR_16 | -UCC_SLOW_GUMR_L_RDCR_16 ); +qe_clrsetbits_be32 (&uccp->gumr_l, +UCC_SLOW_GUMR_L_MODE_MASK |UCC_SLOW_GUMR_L_TDCR_MASK |UCC_SLOW_GUMR_L_RDCR_MASK , +UCC_SLOW_GUMR_L_MODE_QMC |UCC_SLOW_GUMR_L_TDCR_16 |UCC_SLOW_GUMR_L_RDCR_16 ); -clrsetbits_be32 (&uccp->gumr_h, -UCC_SLOW_GUMR_H_RFW |UCC_SLOW_GUMR_H_RSYN , -UCC_SLOW_GUMR_H_SUART |UCC_SLOW_GUMR_H_TRX | -UCC_SLOW_GUMR_H_TTX |UCC_SLOW_GUMR_H_TFL ); +qe_clrsetbits_be32 (&uccp->gumr_h, +UCC_SLOW_GUMR_H_RFW |UCC_SLOW_GUMR_H_RSYN , +UCC_SLOW_GUMR_H_SUART |UCC_SLOW_GUMR_H_TRX |UCC_SLOW_GUMR_H_TTX |UCC_SLOW_GUMR_H_TFL );#ifdef LOOPBACK -clrsetbits_be32 (&uccp->gumr_l,UCC_SLOW_GUMR_L_DIAG_MASK , -UCC_SLOW_GUMR_L_DIAG_LOOP ); -clrbits32 (&uccp->gumr_h,UCC_SLOW_GUMR_H_CTSP | -UCC_SLOW_GUMR_H_CDS ); +qe_clrsetbits_be32 (&uccp->gumr_l,UCC_SLOW_GUMR_L_DIAG_MASK , +UCC_SLOW_GUMR_L_DIAG_LOOP ); +qe_clrbits_be32 (&uccp->gumr_h, +UCC_SLOW_GUMR_H_CTSP |UCC_SLOW_GUMR_H_CDS );#endif cecr_subblock =ucc_slow_get_qe_cr_subblock (qe_port->ucc_num);
@@ -801,7 +795,7 @@ static int qe_uart_startup(struct uart_port *port) }/* Startup rx-int */ -setbits16 (&qe_port->uccp->uccm,UCC_UART_UCCE_RX ); +qe_setbits_be16 (&qe_port->uccp->uccm,UCC_UART_UCCE_RX );ucc_slow_enable (qe_port->us_private,COMM_DIR_RX_AND_TX );return 0 ;
@@ -837,7 +831,7 @@ static void qe_uart_shutdown(struct uart_port *port)/* Stop uarts */ ucc_slow_disable (qe_port->us_private,COMM_DIR_RX_AND_TX ); -clrbits16 (&uccp->uccm,UCC_UART_UCCE_TX |UCC_UART_UCCE_RX ); +qe_clrbits_be16 (&uccp->uccm,UCC_UART_UCCE_TX |UCC_UART_UCCE_RX );/* Shut them really down and reinit buffer descriptors */ ucc_slow_graceful_stop_tx (qe_port->us_private);
@@ -857,9 +851,9 @@ static void qe_uart_set_termios(struct uart_port *port,struct ucc_slow __iomem *uccp = qe_port->uccp;unsigned int baud;unsigned long flags; -u16 upsmr =in_be16 (&uccp->upsmr); +u16 upsmr =qe_ioread16be (&uccp->upsmr);struct ucc_uart_pram __iomem *uccup = qe_port->uccup; -u16 supsmr =in_be16 (&uccup->supsmr); +u16 supsmr =qe_ioread16be (&uccup->supsmr);u8 char_length =2 ;/* 1 + CL + PEN + 1 + SL */ /* Character length programmed into the mode register is the
@@ -957,10 +951,10 @@ static void qe_uart_set_termios(struct uart_port *port,/* Update the per-port timeout. */ uart_update_timeout (port, termios->c_cflag, baud); -out_be16 (&uccp->upsmr, upsmr); +qe_iowrite16be (upsmr, &uccp->upsmr);if (soft_uart) { -out_be16 (&uccup->supsmr, supsmr); -out_8 (&uccup->rx_length, char_length); +qe_iowrite16be (supsmr, &uccup->supsmr); +qe_iowrite8 (char_length, &uccup->rx_length);/* Soft-UART requires a 1X multiplier for TX */ qe_setbrg (qe_port->us_info.rx_clock, baud,16 );
Signature · 1 line
2.23.0
PATCH v4 30/47 serial: ucc_uart: factor out soft_uart initialization
In reply to Rasmus VillemoesThe "soft uart" mechanism is a workaround for a silicon bug which (as far as I know) only affects some PPC-based SOCs.
The code that determines which microcode blob to request relies on some powerpc-specific bits (e.g. the mfspr(SPRN_SVR) and hence also the asm/reg.h header). This makes it a little awkward to allow this driver to be built for non-PPC based SOCs with a QE, even if they are not affected by that silicon bug and thus don't need any of the Soft UART logic.
There's no way around guarding those bits with some ifdeffery, so to keep that isolated, factor out the do-we-need-soft-uart-and-if-so-handle-the-firmware to a separate function, which we can then easily stub out for non-PPC.
--- drivers/tty/serial/ucc_uart.c | 110 ++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 52 deletions(-)
drivers/tty/serial/ucc_uart.c +58 -52
@@ -1183,70 +1183,76 @@ static void uart_firmware_cont(const struct firmware *fw, void *context)release_firmware (fw); } -static int ucc_uart_probe (struct platform_device *ofdev) +static int soft_uart_init (struct platform_device *ofdev) {struct device_node *np = ofdev->dev.of_node; -const unsigned int *iprop;/* Integer OF properties */ -const char *sprop;/* String OF properties */ -struct uart_qe_port *qe_port =NULL ; -struct resource res; +struct qe_firmware_info *qe_fw_info;int ret; -/* -* Determine if we need Soft-UART mode -*/ if (of_find_property (np,"soft-uart" ,NULL )) {dev_dbg (&ofdev->dev,"using Soft-UART mode\n" ); soft_uart =1 ; + }else { +return 0 ; } -/* -* If we are using Soft-UART, determine if we need to upload the -* firmware, too. -*/ -if (soft_uart) { -struct qe_firmware_info *qe_fw_info; - - qe_fw_info =qe_get_firmware_info (); - -/* Check if the firmware has been uploaded. */ -if (qe_fw_info &&strstr (qe_fw_info->id,"Soft-UART" )) { - firmware_loaded =1 ; - }else { -char filename[32 ]; -unsigned int soc; -unsigned int rev_h; -unsigned int rev_l; - - soc =soc_info (&rev_h, &rev_l); -if (!soc) { -dev_err (&ofdev->dev,"unknown CPU model\n" ); -return -ENXIO ; - } -sprintf (filename,"fsl_qe_ucode_uart_%u_%u%u.bin" , - soc, rev_h, rev_l); - -dev_info (&ofdev->dev,"waiting for firmware %s\n" , - filename); + qe_fw_info =qe_get_firmware_info (); -/* -* We call request_firmware_nowait instead of -* request_firmware so that the driver can load and -* initialize the ports without holding up the rest of -* the kernel. If hotplug support is enabled in the -* kernel, then we use it. -*/ - ret =request_firmware_nowait (THIS_MODULE , -FW_ACTION_HOTPLUG , filename, &ofdev->dev, -GFP_KERNEL , &ofdev->dev, uart_firmware_cont); -if (ret) { -dev_err (&ofdev->dev, -"could not load firmware %s\n" , - filename); -return ret; - } +/* Check if the firmware has been uploaded. */ +if (qe_fw_info &&strstr (qe_fw_info->id,"Soft-UART" )) { + firmware_loaded =1 ; + }else { +char filename[32 ]; +unsigned int soc; +unsigned int rev_h; +unsigned int rev_l; + + soc =soc_info (&rev_h, &rev_l); +if (!soc) { +dev_err (&ofdev->dev,"unknown CPU model\n" ); +return -ENXIO ; + } +sprintf (filename,"fsl_qe_ucode_uart_%u_%u%u.bin" , + soc, rev_h, rev_l); + +dev_info (&ofdev->dev,"waiting for firmware %s\n" , + filename); + +/* +* We call request_firmware_nowait instead of +* request_firmware so that the driver can load and +* initialize the ports without holding up the rest of +* the kernel. If hotplug support is enabled in the +* kernel, then we use it. +*/ + ret =request_firmware_nowait (THIS_MODULE , +FW_ACTION_HOTPLUG , filename, &ofdev->dev, +GFP_KERNEL , &ofdev->dev, uart_firmware_cont); +if (ret) { +dev_err (&ofdev->dev, +"could not load firmware %s\n" , + filename); +return ret; } } +return 0 ; +} + +static int ucc_uart_probe (struct platform_device *ofdev) +{ +struct device_node *np = ofdev->dev.of_node; +const unsigned int *iprop;/* Integer OF properties */ +const char *sprop;/* String OF properties */ +struct uart_qe_port *qe_port =NULL ; +struct resource res; +int ret; + +/* +* Determine if we need Soft-UART mode +*/ + ret =soft_uart_init (ofdev); +if (ret) +return ret; qe_port =kzalloc (sizeof (struct uart_qe_port ),GFP_KERNEL );if (!qe_port) {
Signature · 1 line
2.23.0
Timur Tabi
maintainerRe: [PATCH v4 30/47] serial: ucc_uart: factor out soft_uart initialization
drivers/tty/serial/ucc_uart.c static void uart_firmware_cont(const struct firmware *fw, void *context) · line 1197
Quoted 10 lines · Rasmus Villemoes
drivers/tty/serial/ucc_uart.c +2
-3-/* -* Determine if we need Soft-UART mode -*/ if (of_find_property (np,"soft-uart" ,NULL )) {dev_dbg (&ofdev->dev,"using Soft-UART mode\n" ); soft_uart =1 ; + }else { +return 0 ; }
How about:
if (!of_find_property(np, "soft-uart", NULL))
return 0;
And I think you should be able to get rid of the "soft_uart" variable.
Re: [PATCH v4 30/47] serial: ucc_uart: factor out soft_uart initialization
Quoted 13 lines · Timur Tabi
drivers/tty/serial/ucc_uart.c static void uart_firmware_cont(const struct firmware *fw, void *context) · line 1197
Quoted 10 lines · Rasmus Villemoes
drivers/tty/serial/ucc_uart.c +2
-3-/* -* Determine if we need Soft-UART mode -*/ if (of_find_property (np,"soft-uart" ,NULL )) {dev_dbg (&ofdev->dev,"using Soft-UART mode\n" ); soft_uart =1 ; + }else { +return 0 ; }
Quoted 4 lines
How about:
if (!of_find_property(np, "soft-uart", NULL))
return 0;
of_property_read_bool() if anything. But I didn't want to do that kind of transformation - just a pure "move this code out and fix the indentation" with the minor edits needed to hook it back up where it came from.
Quoted 1 line
And I think you should be able to get rid of the "
soft_uart" variable.
Eh, no, it's used in several other places in the driver. I kind of hope gcc is smart enough to see that in the !PPC32 case it is a static, never-assigned-to, never-escapes variable so all the "if (soft_uart)" branches go away, but that's not really very important.
Rasmus
PATCH v4 31/47 serial: ucc_uart: stub out soft_uart_init for !CONFIG_PPC32
In reply to Rasmus VillemoesThe Soft UART hack is only needed for some PPC-based SOCs. To allow building this driver for non-PPC, guard soft_uart_init() and its helpers by CONFIG_PPC32, and use a no-op soft_uart_init() otherwise.
--- drivers/tty/serial/ucc_uart.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/tty/serial/ucc_uart.c +16 -1
@@ -33,7 +33,10 @@#include <linux/firmware.h> #include <soc/fsl/cpm.h> -#include <asm/reg.h> + +#ifdef CONFIG_PPC32 +#include <asm/reg.h> /* mfspr, SPRN_SVR */ +#endif /* * The GUMR flag for Soft UART. This would normally be defined in qe.h,
@@ -1096,6 +1099,8 @@ static const struct uart_ops qe_uart_pops = { .verify_port = qe_uart_verify_port, }; + +#ifdef CONFIG_PPC32 /* * Obtain the SOC model number and revision level *
@@ -1238,6 +1243,16 @@ static int soft_uart_init(struct platform_device *ofdev) return 0; } +#else /* !CONFIG_PPC32 */ + +static int soft_uart_init (struct platform_device *ofdev) +{ +return 0 ; +} + +#endif + +static int ucc_uart_probe (struct platform_device *ofdev) {struct device_node *np = ofdev->dev.of_node;
Signature · 1 line
2.23.0
PATCH v4 32/47 serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
In reply to Rasmus VillemoesFor this to work correctly on little-endian hosts, don't access the device-tree properties directly in native endianness, but use the of_property_read_u32() helper.
--- drivers/tty/serial/ucc_uart.c | 41 +++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-)
drivers/tty/serial/ucc_uart.c +17 -24
@@ -1256,10 +1256,10 @@ static int soft_uart_init(struct platform_device *ofdev)static int ucc_uart_probe (struct platform_device *ofdev) {struct device_node *np = ofdev->dev.of_node; -const unsigned int *iprop;/* Integer OF properties */ const char *sprop;/* String OF properties */ struct uart_qe_port *qe_port =NULL ;struct resource res; +u32 val;int ret;/*
@@ -1290,23 +1290,19 @@ static int ucc_uart_probe(struct platform_device *ofdev)/* Get the UCC number (device ID) */ /* UCCs are numbered 1-7 */ - iprop =of_get_property (np,"cell-index" ,NULL ); -if (!iprop) { - iprop =of_get_property (np,"device-id" ,NULL ); -if (!iprop) { -dev_err (&ofdev->dev,"UCC is unspecified in " -"device tree\n" ); - ret = -EINVAL ; - goto out_free; - } +if (of_property_read_u32 (np,"cell-index" , &val) && +of_property_read_u32 (np,"device-id" , &val)) { +dev_err (&ofdev->dev,"UCC is unspecified in device tree\n" ); + ret = -EINVAL ; + goto out_free; } -if ((*iprop <1 ) || (*iprop >UCC_MAX_NUM )) { -dev_err (&ofdev->dev,"no support for UCC%u\n" , *iprop); +if (val <1 || val >UCC_MAX_NUM ) { +dev_err (&ofdev->dev,"no support for UCC%u\n" , val); ret = -ENODEV ; goto out_free; } - qe_port->ucc_num = *iprop -1 ; + qe_port->ucc_num = val -1 ;/* * In the future, we should not require the BRG to be specified in the
@@ -1350,13 +1346,12 @@ static int ucc_uart_probe(struct platform_device *ofdev) }/* Get the port number, numbered 0-3 */ - iprop =of_get_property (np,"port-number" ,NULL ); -if (!iprop) { +if (of_property_read_u32 (np,"port-number" , &val)) {dev_err (&ofdev->dev,"missing port-number in device tree\n" ); ret = -EINVAL ; goto out_free; } - qe_port->port.line = *iprop; + qe_port->port.line = val;if (qe_port->port.line >=UCC_MAX_UART ) {dev_err (&ofdev->dev,"port-number must be 0-%u\n" ,UCC_MAX_UART -1 );
@@ -1386,31 +1381,29 @@ static int ucc_uart_probe(struct platform_device *ofdev) } } - iprop =of_get_property (np,"brg-frequency" ,NULL ); -if (!iprop) { +if (of_property_read_u32 (np,"brg-frequency" , &val)) {dev_err (&ofdev->dev,"missing brg-frequency in device tree\n" ); ret = -EINVAL ; goto out_np; } -if (*iprop) - qe_port->port.uartclk = *iprop; +if (val) + qe_port->port.uartclk = val;else {/* * Older versions of U-Boot do not initialize the brg-frequency * property, so in this case we assume the BRG frequency is * half the QE bus frequency. */ - iprop =of_get_property (np,"bus-frequency" ,NULL ); -if (!iprop) { +if (of_property_read_u32 (np,"bus-frequency" , &val)) {dev_err (&ofdev->dev,"missing QE bus-frequency in device tree\n" ); ret = -EINVAL ; goto out_np; } -if (*iprop) - qe_port->port.uartclk = *iprop /2 ; +if (val) + qe_port->port.uartclk = val /2 ;else {dev_err (&ofdev->dev,"invalid QE bus-frequency in device tree\n" );
Signature · 1 line
2.23.0
Timur Tabi
maintainerRe: [PATCH v4 32/47] serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
drivers/tty/serial/ucc_uart.c static int ucc_uart_probe(struct platform_device *ofdev) · line 1398
Quoted 11 lines · Rasmus Villemoes
drivers/tty/serial/ucc_uart.c +2
-2-if (*iprop) - qe_port->port.uartclk = *iprop; +if (val) + qe_port->port.uartclk = val;else {/* * Older versions of U-Boot do not initialize the brg-frequency * property, so in this case we assume the BRG frequency is * half the QE bus frequency. */
This bug in older U-Boots is definitely PowerPC-specific, so could you change this so that it reports an error on ARM if brg-frequency is zero, and displays a warning on PowerPC?
Re: [PATCH v4 32/47] serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
Quoted 14 lines · Timur Tabi
drivers/tty/serial/ucc_uart.c static int ucc_uart_probe(struct platform_device *ofdev) · line 1398
Quoted 11 lines · Rasmus Villemoes
drivers/tty/serial/ucc_uart.c +2
-2-if (*iprop) - qe_port->port.uartclk = *iprop; +if (val) + qe_port->port.uartclk = val;else {/* * Older versions of U-Boot do not initialize the brg-frequency * property, so in this case we assume the BRG frequency is * half the QE bus frequency. */
Quoted 4 lines
This bug in older U-Boots is definitely PowerPC-specific, so could you change this so that it reports an error on ARM if brg-frequency is zero, and displays a warning on PowerPC?
That would be a separate patch, this patch is only concerned with eliminating the implicit assumption of the host being big-endian. And there's already been some pushback to adding arch-specific ifdefs (which I agree with, but as I responded there see as the lesser evil), so unless there's a very good reason to add that complexity, I'd rather not.
Rasmus
Timur Tabi
maintainerRe: [PATCH v4 32/47] serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
Quoted 5 lines · Rasmus Villemoes
That would be a separate patch, this patch is only concerned with eliminating the implicit assumption of the host being big-endian. And there's already been some pushback to adding arch-specific ifdefs (which I agree with, but as I responded there see as the lesser evil), so unless there's a very good reason to add that complexity, I'd rather not.
We don't want to encourage people to introduce device trees that don't have the brg-frequency property in them.
Scott Wood
maintainerRe: [PATCH v4 32/47] serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
Quoted 9 lines · Timur Tabi
Quoted 5 lines · Rasmus Villemoes
That would be a separate patch, this patch is only concerned with eliminating the implicit assumption of the host being big-endian. And there's already been some pushback to adding arch-specific ifdefs (which I agree with, but as I responded there see as the lesser evil), so unless there's a very good reason to add that complexity, I'd rather not.
We don't want to encourage people to introduce device trees that don't have the brg-frequency property in them.
Yeah, workarounds like this should be as targeted as possible. If we knew the specific chips/boards on which U-Boot has this problem, then limiting it to those would have been even better (e.g. fix up the device tree from the platform code), but at this point containing the damage to PPC seems like the most reasonable approach. It's not relevant to this specific patch, but it is relevant to a patchset expanding the set of platforms on which this code builds.
-Scott
Timur Tabi
maintainerRe: [PATCH v4 32/47] serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
In reply to Rasmus Villemoesdrivers/tty/serial/ucc_uart.c static int ucc_uart_probe(struct platform_device *ofdev) · line 1294
Quoted 3 lines · Rasmus Villemoes
drivers/tty/serial/ucc_uart.c +2
-0+if (of_property_read_u32 (np,"cell-index" , &val) && +of_property_read_u32 (np,"device-id" , &val)) {
I know that this is technically correct, but it's obfuscated IMHO. 'val' is set correctly only when of_property_read_u32(...) is "false", which is doubly-weird because of_property_read_u32(...) doesn't actually return a boolean.
I would rather you break this into two if-statements like the original code.
Re: [PATCH v4 32/47] serial: ucc_uart: use of_property_read_u32() in ucc_uart_probe()
Quoted 6 lines · Timur Tabi
drivers/tty/serial/ucc_uart.c static int ucc_uart_probe(struct platform_device *ofdev) · line 1294
Quoted 3 lines · Rasmus Villemoes
drivers/tty/serial/ucc_uart.c +2
-0+if (of_property_read_u32 (np,"cell-index" , &val) && +of_property_read_u32 (np,"device-id" , &val)) {
Quoted 7 lines
I know that this is technically correct, but it's obfuscated IMHO. 'val' is set correctly only when
of_property_read_u32(...)is "false", which is doubly-weird becauseof_property_read_u32(...)doesn't actually return a boolean.I would rather you break this into two if-statements like the original code.
Sure, I can do that.
PATCH v4 33/47 serial: ucc_uart: access __be32 field using be32_to_cpu
In reply to Rasmus VillemoesThe buf member of struct qe_bd is a __be32, so to make this work on little-endian hosts, use be32_to_cpu when reading it.
--- drivers/tty/serial/ucc_uart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/ucc_uart.c +3 -3
@@ -343,7 +343,7 @@ static int qe_uart_tx_pump(struct uart_qe_port *qe_port)/* Pick next descriptor and fill from buffer */ bdp = qe_port->tx_cur; - p =qe2cpu_addr (bdp->buf, qe_port); + p =qe2cpu_addr (be32_to_cpu (bdp->buf), qe_port); *p++ = port->x_char;qe_iowrite16be (1 , &bdp->length);
@@ -371,7 +371,7 @@ static int qe_uart_tx_pump(struct uart_qe_port *qe_port)while (!(qe_ioread16be (&bdp->status) &BD_SC_READY ) && (xmit->tail != xmit->head)) { count =0 ; - p =qe2cpu_addr (bdp->buf, qe_port); + p =qe2cpu_addr (be32_to_cpu (bdp->buf), qe_port);while (count < qe_port->tx_fifosize) { *p++ = xmit->buf[xmit->tail]; xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 );
@@ -491,7 +491,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port) }/* get pointer */ - cp =qe2cpu_addr (bdp->buf, qe_port); + cp =qe2cpu_addr (be32_to_cpu (bdp->buf), qe_port);/* loop through the buffer */ while (i-- >0 ) {
Signature · 1 line
2.23.0
PATCH v4 34/47 soc: fsl: qe: change return type of cpm_muram_alloc() to s32
In reply to Rasmus VillemoesThere are a number of problems with cpm_muram_alloc() and its callers. Most callers assign the return value to some variable and then use IS_ERR_VALUE to check for allocation failure. However, when that variable is not sizeof(long), this leads to warnings - and it is indeed broken to do e.g.
u32 foo = cpm_muram_alloc(); if (IS_ERR_VALUE(foo))
on a 64-bit platform, since the condition
foo >= (unsigned long)-ENOMEM
is tautologically false. There are also callers that ignore the possibility of error, and then there are those that check for error by comparing the return value to 0...
One could fix that by changing all callers to store the return value temporarily in an "unsigned long" and test that. However, use of IS_ERR_VALUE() is error-prone and should be restricted to things which are inherently long-sized (stuff in pt_regs etc.). Instead, let's aim for changing to the standard kernel style
int foo = cpm_muram_alloc();
if (foo < 0)
deal_with_it()
some->where = foo;Changing the return type from unsigned long to s32 (aka signed int) doesn't change the value that gets stored into any of the callers' variables except if the caller was storing the result in a u64 _and_ the allocation failed, so in itself this patch should be a no-op.
Another problem with cpm_muram_alloc() is that it can certainly validly return 0 - and except if some cpm_muram_alloc_fixed() call interferes, the very first cpm_muram_alloc() call will return just that. But that shows that both ucc_slow_free() and ucc_fast_free() are buggy, since they assume that a value of 0 means "that field was never allocated". We'll later change cpm_muram_free() to accept (and ignore) a negative offset, so callers can use a sentinel of -1 instead of 0 and just unconditionally call cpm_muram_free().
--- drivers/soc/fsl/qe/qe_common.c | 29 ++++++++++++++++------------- include/soc/fsl/qe/qe.h | 16 ++++++++-------- 2 files changed, 24 insertions(+), 21 deletions(-)
drivers/soc/fsl/qe/qe_common.c +16 -13
@@ -32,7 +32,7 @@ static phys_addr_t muram_pbase;struct muram_block {struct list_head head; -unsigned long start; +s32 start;int size; };
@@ -110,13 +110,14 @@ int cpm_muram_init(void)* @algo: algorithm for alloc. * @data: data for genalloc's algorithm. * -* This function returns an offset into the muram area. +* This function returns a non-negative offset into the muram area, or +* a negative errno on failure. */ -static unsigned long cpm_muram_alloc_common (unsigned long size, -genpool_algo_t algo,void *data) +static s32 cpm_muram_alloc_common (unsigned long size, +genpool_algo_t algo,void *data) {struct muram_block *entry; -unsigned long start; +s32 start;if (!muram_pool &&cpm_muram_init ()) goto out2;
@@ -137,7 +138,7 @@ static unsigned long cpm_muram_alloc_common(unsigned long size, out1:gen_pool_free (muram_pool, start, size); out2: -return (unsigned long )-ENOMEM ; +return -ENOMEM ; }/*
@@ -145,13 +146,14 @@ static unsigned long cpm_muram_alloc_common(unsigned long size,* @size: number of bytes to allocate * @align: requested alignment, in bytes * -* This function returns an offset into the muram area. +* This function returns a non-negative offset into the muram area, or +* a negative errno on failure. * Use cpm_dpram_addr() to get the virtual address of the area. * Use cpm_muram_free() to free the allocation. */ -unsigned long cpm_muram_alloc (unsigned long size,unsigned long align) +s32 cpm_muram_alloc (unsigned long size,unsigned long align) { -unsigned long start; +s32 start;unsigned long flags;struct genpool_data_align muram_pool_data;
@@ -168,7 +170,7 @@ EXPORT_SYMBOL(cpm_muram_alloc);* cpm_muram_free - free a chunk of multi-user ram * @offset: The beginning of the chunk as returned by cpm_muram_alloc(). */ -int cpm_muram_free (unsigned long offset) +int cpm_muram_free (s32 offset) {unsigned long flags;int size;
@@ -194,13 +196,14 @@ EXPORT_SYMBOL(cpm_muram_free);* cpm_muram_alloc_fixed - reserve a specific region of multi-user ram * @offset: offset of allocation start address * @size: number of bytes to allocate -* This function returns an offset into the muram area +* This function returns @offset if the area was available, a negative +* errno otherwise. * Use cpm_dpram_addr() to get the virtual address of the area. * Use cpm_muram_free() to free the allocation. */ -unsigned long cpm_muram_alloc_fixed (unsigned long offset,unsigned long size) +s32 cpm_muram_alloc_fixed (unsigned long offset,unsigned long size) { -unsigned long start; +long start;unsigned long flags;struct genpool_data_fixed muram_pool_data_fixed;
include/soc/fsl/qe/qe.h +8 -8
@@ -98,26 +98,26 @@ static inline void qe_reset(void) {}int cpm_muram_init (void );#if defined(CONFIG_CPM ) || defined(CONFIG_QUICC_ENGINE ) -unsigned long cpm_muram_alloc (unsigned long size,unsigned long align); -int cpm_muram_free (unsigned long offset); -unsigned long cpm_muram_alloc_fixed (unsigned long offset,unsigned long size); +s32 cpm_muram_alloc (unsigned long size,unsigned long align); +int cpm_muram_free (s32 offset); +s32 cpm_muram_alloc_fixed (unsigned long offset,unsigned long size);void __iomem *cpm_muram_addr (unsigned long offset);unsigned long cpm_muram_offset (void __iomem *addr);dma_addr_t cpm_muram_dma (void __iomem *addr);#else -static inline unsigned long cpm_muram_alloc (unsigned long size, -unsigned long align) +static inline s32 cpm_muram_alloc (unsigned long size, +unsigned long align) {return -ENOSYS ; } -static inline int cpm_muram_free (unsigned long offset) +static inline int cpm_muram_free (s32 offset) {return -ENOSYS ; } -static inline unsigned long cpm_muram_alloc_fixed (unsigned long offset, -unsigned long size) +static inline s32 cpm_muram_alloc_fixed (unsigned long offset, +unsigned long size) {return -ENOSYS ; }
Signature · 1 line
2.23.0
Qiang Zhao
maintainerRE: [PATCH v4 34/47] soc: fsl: qe: change return type of cpm_muram_alloc() to s32
Quoted 13 lines · On Fri, Nov 8, 2019 at 21:01 Rasmus Villemoes <[email protected]> wrote:
-----Original Message-----
From: Rasmus Villemoes <[email protected]>
Sent: 2019年11月8日 21:01
To: Qiang Zhao <[email protected]>; Leo Li <[email protected]>; Christophe Leroy <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Scott Wood <[email protected]>; Rasmus Villemoes <[email protected]>
Subject: [PATCH v4 34/47] soc: fsl: qe: change return type ofcpm_muram_alloc()to s32-unsigned long
cpm_muram_alloc_fixed(unsigned long offset, unsigned long size)
drivers/soc/fsl/qe/qe_common.c EXPORT_SYMBOL(cpm_muram_free); · line 208
Quoted 6 lines
drivers/soc/fsl/qe/qe_common.c +2
-1+s32 cpm_muram_alloc_fixed (unsigned long offset,unsigned long size) { -unsigned long start; +long start;unsigned long flags;struct genpool_data_fixed muram_pool_data_fixed;
"start" should be s32 here too?
Best Regards
Qiang Zhao
Re: [PATCH v4 34/47] soc: fsl: qe: change return type of cpm_muram_alloc() to s32
Quoted 12 lines · Qiang Zhao
drivers/soc/fsl/qe/qe_common.c EXPORT_SYMBOL(cpm_muram_free); · line 208
Quoted 8 lines · On Fri, Nov 8, 2019 at 21:01 Rasmus Villemoes <[email protected]> wrote:
-unsigned long
cpm_muram_alloc_fixed(unsigned long offset, unsigned long size)drivers/soc/fsl/qe/qe_common.c +2
-1+s32 cpm_muram_alloc_fixed (unsigned long offset,unsigned long size) { -unsigned long start; +long start;unsigned long flags;struct genpool_data_fixed muram_pool_data_fixed;"start" should be s32 here too?
Yes, of course. Good catch.
Rasmus
PATCH v4 35/47 soc: fsl: qe: make cpm_muram_free() return void
In reply to Rasmus VillemoesNobody uses the return value from cpm_muram_free, and functions that free resources usually return void. One could imagine a use for a "how much have I allocated" a la ksize(), but knowing how much one had access to after the fact is useless.
--- drivers/soc/fsl/qe/qe_common.c | 3 +-- include/soc/fsl/qe/qe.h | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/soc/fsl/qe/qe_common.c +1 -2
@@ -170,7 +170,7 @@ EXPORT_SYMBOL(cpm_muram_alloc);* cpm_muram_free - free a chunk of multi-user ram * @offset: The beginning of the chunk as returned by cpm_muram_alloc(). */ -int cpm_muram_free (s32 offset) +void cpm_muram_free (s32 offset) {unsigned long flags;int size;
@@ -188,7 +188,6 @@ int cpm_muram_free(s32 offset) }gen_pool_free (muram_pool, offset +GENPOOL_OFFSET , size);spin_unlock_irqrestore (&cpm_muram_lock, flags); -return size; }EXPORT_SYMBOL (cpm_muram_free);
include/soc/fsl/qe/qe.h +2 -3
@@ -99,7 +99,7 @@ int cpm_muram_init(void);#if defined(CONFIG_CPM ) || defined(CONFIG_QUICC_ENGINE )s32 cpm_muram_alloc (unsigned long size,unsigned long align); -int cpm_muram_free (s32 offset); +void cpm_muram_free (s32 offset);s32 cpm_muram_alloc_fixed (unsigned long offset,unsigned long size);void __iomem *cpm_muram_addr (unsigned long offset);unsigned long cpm_muram_offset (void __iomem *addr);
@@ -111,9 +111,8 @@ static inline s32 cpm_muram_alloc(unsigned long size,return -ENOSYS ; } -static inline int cpm_muram_free (s32 offset) +static inline void cpm_muram_free (s32 offset) { -return -ENOSYS ; } static inline s32 cpm_muram_alloc_fixed(unsigned long offset,
Signature · 1 line
2.23.0
PATCH v4 36/47 soc: fsl: qe: make cpm_muram_free() ignore a negative offset
In reply to Rasmus VillemoesThis allows one to simplify callers since they can store a negative value as a sentinel to indicate "this was never allocated" (or store the -ENOMEM from an allocation failure) and then call cpm_muram_free() unconditionally.
--- drivers/soc/fsl/qe/qe_common.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/soc/fsl/qe/qe_common.c +3 -0
@@ -176,6 +176,9 @@ void cpm_muram_free(s32 offset)int size;struct muram_block *tmp; +if (offset <0 ) +return ; + size =0 ;spin_lock_irqsave (&cpm_muram_lock, flags);list_for_each_entry (tmp, &muram_block_list, head) {
Signature · 1 line
2.23.0
PATCH v4 37/47 soc: fsl: qe: drop broken lazy call of cpm_muram_init()
In reply to Rasmus Villemoescpm_muram_alloc_common() tries to support a kind of lazy initialization - if the muram_pool has not been created yet, it calls cpm_muram_init(). Now, cpm_muram_alloc_common() is always called under
spin_lock_irqsave(&cpm_muram_lock, flags);
and cpm_muram_init() does gen_pool_create() (which implies a GFP_KERNEL allocation) and ioremap(), not to mention the fun that ensues from cpm_muram_init() doing
spin_lock_init(&cpm_muram_lock);
In other words, this has never worked, so nobody can have been relying on it.
cpm_muram_init() is called from a subsys_initcall (either from cpm_init() in arch/powerpc/sysdev/cpm_common.c or, via qe_reset(), from qe_init() in drivers/soc/fsl/qe/qe.c).
--- drivers/soc/fsl/qe/qe_common.c | 3 --- 1 file changed, 3 deletions(-)
drivers/soc/fsl/qe/qe_common.c +0 -3
@@ -119,9 +119,6 @@ static s32 cpm_muram_alloc_common(unsigned long size,struct muram_block *entry;s32 start; -if (!muram_pool &&cpm_muram_init ()) - goto out2; - start =gen_pool_alloc_algo (muram_pool, size, algo, data);if (!start) goto out2;
Signature · 1 line
2.23.0
PATCH v4 38/47 soc: fsl: qe: refactor cpm_muram_alloc_common to prevent BUG on error path
In reply to Rasmus VillemoesIf the kmalloc() fails, we try to undo the gen_pool allocation we've just done. Unfortunately, start has already been modified to subtract the GENPOOL_OFFSET bias, so we're freeing something that very likely doesn't exist in the gen_pool, meaning we hit the
kernel BUG at lib/genalloc.c:399!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM ... [<803fd0e8>] (gen_pool_free) from [<80426bc8>] (cpm_muram_alloc_common+0xb0/0xc8) [<80426bc8>] (cpm_muram_alloc_common) from [<80426c28>] (cpm_muram_alloc+0x48/0x80) [<80426c28>] (cpm_muram_alloc) from [<80428214>] (ucc_slow_init+0x110/0x4f0) [<80428214>] (ucc_slow_init) from [<8044a718>] (qe_uart_request_port+0x3c/0x1d8)
(this was tested by just injecting a random failure by adding "|| (get_random_int()&7) == 0" to the "if (!entry)" condition).
Refactor the code so we do the kmalloc() first, meaning that's the thing that needs undoing in case gen_pool_alloc_algo() then fails. This allows a later cleanup to move the locking from the callers into the _common function, keeping the kmalloc() out of the critical region and then, hopefully (if all the muram_alloc callers allow) change it to a GFP_KERNEL allocation.
--- drivers/soc/fsl/qe/qe_common.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/soc/fsl/qe/qe_common.c +7 -9
@@ -119,23 +119,21 @@ static s32 cpm_muram_alloc_common(unsigned long size,struct muram_block *entry;s32 start; + entry =kmalloc (sizeof (*entry),GFP_ATOMIC ); +if (!entry) +return -ENOMEM ; start =gen_pool_alloc_algo (muram_pool, size, algo, data); -if (!start) - goto out2; +if (!start) { +kfree (entry); +return -ENOMEM ; + } start = start -GENPOOL_OFFSET ;memset_io (cpm_muram_addr (start),0 , size); - entry =kmalloc (sizeof (*entry),GFP_ATOMIC ); -if (!entry) - goto out1; entry->start = start; entry->size = size;list_add (&entry->head, &muram_block_list);return start; -out1: -gen_pool_free (muram_pool, start, size); -out2: -return -ENOMEM ; }/*
Signature · 1 line
2.23.0
PATCH v4 39/47 soc: fsl: qe: avoid IS_ERR_VALUE in ucc_slow.c
In reply to Rasmus VillemoesWhen trying to build this for a 64-bit platform, one gets warnings from using IS_ERR_VALUE on something which is not sizeof(long).
Instead, change the various *_offset fields to store a signed integer, and simply check for a negative return from qe_muram_alloc(). Since qe_muram_free() now accepts and ignores a negative argument, we only need to make sure these fields are initialized with -1, and we can just unconditionally call qe_muram_free() in ucc_slow_free().
Note that the error case for us_pram_offset failed to set that field to 0 (which, as noted earlier, is anyway a bogus sentinel value).
--- drivers/soc/fsl/qe/ucc_slow.c | 22 +++++++++------------- include/soc/fsl/qe/ucc_slow.h | 6 +++--- 2 files changed, 12 insertions(+), 16 deletions(-)
drivers/soc/fsl/qe/ucc_slow.c +9 -13
@@ -154,6 +154,9 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc __func__);return -ENOMEM ; } + uccs->rx_base_offset =-1 ; + uccs->tx_base_offset =-1 ; + uccs->us_pram_offset =-1 ;/* Fill slow UCC structure */ uccs->us_info = us_info;
@@ -179,7 +182,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc/* Get PRAM base */ uccs->us_pram_offset =qe_muram_alloc (UCC_SLOW_PRAM_SIZE ,ALIGNMENT_OF_UCC_SLOW_PRAM ); -if (IS_ERR_VALUE (uccs->us_pram_offset)) { +if (uccs->us_pram_offset <0 ) {printk (KERN_ERR "%s: cannot allocate MURAM for PRAM" , __func__);ucc_slow_free (uccs);return -ENOMEM ;
@@ -206,10 +209,9 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc uccs->rx_base_offset =qe_muram_alloc (us_info->rx_bd_ring_len *sizeof (struct qe_bd ),QE_ALIGNMENT_OF_BD ); -if (IS_ERR_VALUE (uccs->rx_base_offset)) { +if (uccs->rx_base_offset <0 ) {printk (KERN_ERR "%s: cannot allocate %u RX BDs\n" , __func__, us_info->rx_bd_ring_len); - uccs->rx_base_offset =0 ;ucc_slow_free (uccs);return -ENOMEM ; }
@@ -217,9 +219,8 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc uccs->tx_base_offset =qe_muram_alloc (us_info->tx_bd_ring_len *sizeof (struct qe_bd ),QE_ALIGNMENT_OF_BD ); -if (IS_ERR_VALUE (uccs->tx_base_offset)) { +if (uccs->tx_base_offset <0 ) {printk (KERN_ERR "%s: cannot allocate TX BDs" , __func__); - uccs->tx_base_offset =0 ;ucc_slow_free (uccs);return -ENOMEM ; }
@@ -352,14 +353,9 @@ void ucc_slow_free(struct ucc_slow_private * uccs)if (!uccs)return ; -if (uccs->rx_base_offset) -qe_muram_free (uccs->rx_base_offset); - -if (uccs->tx_base_offset) -qe_muram_free (uccs->tx_base_offset); - -if (uccs->us_pram) -qe_muram_free (uccs->us_pram_offset); +qe_muram_free (uccs->rx_base_offset); +qe_muram_free (uccs->tx_base_offset); +qe_muram_free (uccs->us_pram_offset);if (uccs->us_regs)iounmap (uccs->us_regs);
include/soc/fsl/qe/ucc_slow.h +3 -3
@@ -185,7 +185,7 @@ struct ucc_slow_private {struct ucc_slow_info *us_info;struct ucc_slow __iomem *us_regs;/* Ptr to memory map of UCC regs */ struct ucc_slow_pram *us_pram;/* a pointer to the parameter RAM */ -u32 us_pram_offset; +s32 us_pram_offset;int enabled_tx;/* Whether channel is enabled for Tx (ENT) */ int enabled_rx;/* Whether channel is enabled for Rx (ENR) */ int stopped_tx;/* Whether channel has been stopped for Tx
@@ -194,8 +194,8 @@ struct ucc_slow_private {struct list_head confQ;/* frames passed to chip waiting for tx */ u32 first_tx_bd_mask;/* mask is used in Tx routine to save status and length for first BD in a frame */ -u32 tx_base_offset;/* first BD in Tx BD table offset (In MURAM) */ -u32 rx_base_offset;/* first BD in Rx BD table offset (In MURAM) */ +s32 tx_base_offset;/* first BD in Tx BD table offset (In MURAM) */ +s32 rx_base_offset;/* first BD in Rx BD table offset (In MURAM) */ struct qe_bd *confBd;/* next BD for confirm after Tx */ struct qe_bd *tx_bd;/* next BD for new Tx request */ struct qe_bd *rx_bd;/* next BD to collect after Rx */
Signature · 1 line
2.23.0
PATCH v4 40/47 soc: fsl: qe: drop use of IS_ERR_VALUE in qe_sdma_init()
In reply to Rasmus VillemoesNow that qe_muram_alloc() returns s32, adapt qe_sdma_init() and avoid another few IS_ERR_VALUE() uses.
--- drivers/soc/fsl/qe/qe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/soc/fsl/qe/qe.c +3 -3
@@ -365,16 +365,16 @@ EXPORT_SYMBOL(qe_put_snum);static int qe_sdma_init (void ) {struct sdma __iomem *sdma = &qe_immr->sdma; -static unsigned long sdma_buf_offset = (unsigned long )-ENOMEM ; +static s32 sdma_buf_offset = -ENOMEM ;if (!sdma)return -ENODEV ;/* allocate 2 internal temporary buffers (512 bytes size each) for * the SDMA */ -if (IS_ERR_VALUE (sdma_buf_offset)) { +if (sdma_buf_offset <0 ) { sdma_buf_offset =qe_muram_alloc (512 *2 ,4096 ); -if (IS_ERR_VALUE (sdma_buf_offset)) +if (sdma_buf_offset <0 )return -ENOMEM ; }
Signature · 1 line
2.23.0
PATCH v4 41/47 soc: fsl: qe: drop pointless check in qe_sdma_init()
In reply to Rasmus VillemoesThe sdma member of struct qe_immap is not at offset zero, so even if qe_immr wasn't initialized yet (i.e. NULL), &qe_immr->sdma would not be NULL.
--- drivers/soc/fsl/qe/qe.c | 3 --- 1 file changed, 3 deletions(-)
drivers/soc/fsl/qe/qe.c +0 -3
@@ -367,9 +367,6 @@ static int qe_sdma_init(void)struct sdma __iomem *sdma = &qe_immr->sdma;static s32 sdma_buf_offset = -ENOMEM ; -if (!sdma) -return -ENODEV ; -/* allocate 2 internal temporary buffers (512 bytes size each) for * the SDMA */ if (sdma_buf_offset <0 ) {
Signature · 1 line
2.23.0
PATCH v4 42/47 soc: fsl: qe: avoid IS_ERR_VALUE in ucc_fast.c
In reply to Rasmus VillemoesWhen building this on a 64-bit platform gcc rightly warns that the error checking is broken (-ENOMEM stored in an u32 does not compare greater than (unsigned long)-MAX_ERRNO). Instead, change the ucc_fast_[tr]x_virtual_fifo_base_offset members to s32 and use an ordinary check-for-negative. Also, this avoids treating 0 as "this cannot have been returned from qe_muram_alloc() so don't free it".
--- drivers/soc/fsl/qe/ucc_fast.c | 15 ++++++--------- include/soc/fsl/qe/ucc_fast.h | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-)
drivers/soc/fsl/qe/ucc_fast.c +6 -9
@@ -197,6 +197,8 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc __func__);return -ENOMEM ; } + uccf->ucc_fast_tx_virtual_fifo_base_offset =-1 ; + uccf->ucc_fast_rx_virtual_fifo_base_offset =-1 ;/* Fill fast UCC structure */ uccf->uf_info = uf_info;
@@ -265,10 +267,9 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc/* Allocate memory for Tx Virtual Fifo */ uccf->ucc_fast_tx_virtual_fifo_base_offset =qe_muram_alloc (uf_info->utfs,UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT ); -if (IS_ERR_VALUE (uccf->ucc_fast_tx_virtual_fifo_base_offset)) { +if (uccf->ucc_fast_tx_virtual_fifo_base_offset <0 ) {printk (KERN_ERR "%s: cannot allocate MURAM for TX FIFO\n" , __func__); - uccf->ucc_fast_tx_virtual_fifo_base_offset =0 ;ucc_fast_free (uccf);return -ENOMEM ; }
@@ -278,10 +279,9 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** uccqe_muram_alloc (uf_info->urfs +UCC_FAST_RECEIVE_VIRTUAL_FIFO_SIZE_FUDGE_FACTOR ,UCC_FAST_VIRT_FIFO_REGS_ALIGNMENT ); -if (IS_ERR_VALUE (uccf->ucc_fast_rx_virtual_fifo_base_offset)) { +if (uccf->ucc_fast_rx_virtual_fifo_base_offset <0 ) {printk (KERN_ERR "%s: cannot allocate MURAM for RX FIFO\n" , __func__); - uccf->ucc_fast_rx_virtual_fifo_base_offset =0 ;ucc_fast_free (uccf);return -ENOMEM ; }
@@ -384,11 +384,8 @@ void ucc_fast_free(struct ucc_fast_private * uccf)if (!uccf)return ; -if (uccf->ucc_fast_tx_virtual_fifo_base_offset) -qe_muram_free (uccf->ucc_fast_tx_virtual_fifo_base_offset); - -if (uccf->ucc_fast_rx_virtual_fifo_base_offset) -qe_muram_free (uccf->ucc_fast_rx_virtual_fifo_base_offset); +qe_muram_free (uccf->ucc_fast_tx_virtual_fifo_base_offset); +qe_muram_free (uccf->ucc_fast_rx_virtual_fifo_base_offset);if (uccf->uf_regs)iounmap (uccf->uf_regs);
include/soc/fsl/qe/ucc_fast.h +2 -2
@@ -188,9 +188,9 @@ struct ucc_fast_private {int stopped_tx;/* Whether channel has been stopped for Tx (STOP_TX, etc.) */ int stopped_rx;/* Whether channel has been stopped for Rx */ -u32 ucc_fast_tx_virtual_fifo_base_offset;/* pointer to base of Tx +s32 ucc_fast_tx_virtual_fifo_base_offset;/* pointer to base of Tx virtual fifo */ -u32 ucc_fast_rx_virtual_fifo_base_offset;/* pointer to base of Rx +s32 ucc_fast_rx_virtual_fifo_base_offset;/* pointer to base of Rx virtual fifo */ #ifdef STATISTICS u32 tx_frames;/* Transmitted frames counter. */
Signature · 1 line
2.23.0
PATCH v4 43/47 net/wan/fsl_ucc_hdlc: avoid use of IS_ERR_VALUE()
In reply to Rasmus VillemoesWhen building this on a 64-bit platform gcc rightly warns that the error checking is broken (-ENOMEM stored in an u32 does not compare greater than (unsigned long)-MAX_ERRNO). Instead, now that qe_muram_alloc() returns s32, use that type to store the return value and use standard kernel style "ret < 0".
--- drivers/net/wan/fsl_ucc_hdlc.c | 10 +++++----- drivers/net/wan/fsl_ucc_hdlc.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wan/fsl_ucc_hdlc.c +5 -5
@@ -84,8 +84,8 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)int ret, i;void *bd_buffer;dma_addr_t bd_dma_addr; -u32 riptr; -u32 tiptr; +s32 riptr; +s32 tiptr;u32 gumr; ut_info = priv->ut_info;
@@ -195,7 +195,7 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) priv->ucc_pram_offset =qe_muram_alloc (sizeof (struct ucc_hdlc_param ),ALIGNMENT_OF_UCC_HDLC_PRAM ); -if (IS_ERR_VALUE (priv->ucc_pram_offset)) { +if (priv->ucc_pram_offset <0 ) {dev_err (priv->dev,"Can not allocate MURAM for hdlc parameter.\n" ); ret = -ENOMEM ; goto free_tx_bd;
@@ -233,14 +233,14 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)/* Alloc riptr, tiptr */ riptr =qe_muram_alloc (32 ,32 ); -if (IS_ERR_VALUE (riptr)) { +if (riptr <0 ) {dev_err (priv->dev,"Cannot allocate MURAM mem for Receive internal temp data pointer\n" ); ret = -ENOMEM ; goto free_tx_skbuff; } tiptr =qe_muram_alloc (32 ,32 ); -if (IS_ERR_VALUE (tiptr)) { +if (tiptr <0 ) {dev_err (priv->dev,"Cannot allocate MURAM mem for Transmit internal temp data pointer\n" ); ret = -ENOMEM ; goto free_riptr;
drivers/net/wan/fsl_ucc_hdlc.h +1 -1
@@ -98,7 +98,7 @@ struct ucc_hdlc_private {unsigned short tx_ring_size;unsigned short rx_ring_size; -u32 ucc_pram_offset; +s32 ucc_pram_offset;unsigned short encoding;unsigned short parity;
Signature · 1 line
2.23.0
PATCH v4 44/47 net/wan/fsl_ucc_hdlc: fix reading of __be16 registers
In reply to Rasmus VillemoesWhen releasing the allocated muram resource, we rely on reading back the offsets from the riptr/tiptr registers. But those registers are __be16 (and we indeed write them using iowrite16be), so we can't just read them back with a normal C dereference.
This is not currently a real problem, since for now the driver is PPC32-only. But it will soon be allowed to be used on arm and arm64 as well.
--- drivers/net/wan/fsl_ucc_hdlc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wan/fsl_ucc_hdlc.c +2 -2
@@ -732,8 +732,8 @@ static int uhdlc_open(struct net_device *dev)static void uhdlc_memclean (struct ucc_hdlc_private *priv) { -qe_muram_free (priv->ucc_pram->riptr); -qe_muram_free (priv->ucc_pram->tiptr); +qe_muram_free (ioread16be (&priv->ucc_pram->riptr)); +qe_muram_free (ioread16be (&priv->ucc_pram->tiptr));if (priv->rx_bd_base) { dma_free_coherent(priv->dev,
Signature · 1 line
2.23.0
PATCH v4 45/47 net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
In reply to Rasmus VillemoesQiang Zhao points out that these offsets get written to 16-bit registers, and there are some QE platforms with more than 64K muram. So it is possible that qe_muram_alloc() gives us an allocation that can't actually be used by the hardware, so detect and reject that.
--- drivers/net/wan/fsl_ucc_hdlc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wan/fsl_ucc_hdlc.c +5 -0
@@ -245,6 +245,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) ret = -ENOMEM ; goto free_riptr; } +if (riptr != (u16 )riptr || tiptr != (u16 )tiptr) { +dev_err (priv->dev,"MURAM allocation out of addressable range\n" ); + ret = -ENOMEM ; + goto free_tiptr; + }/* Set RIPTR, TIPTR */ iowrite16be (riptr, &priv->ucc_pram->riptr);
Signature · 1 line
2.23.0
Timur Tabi
maintainerRe: [PATCH v4 45/47] net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
drivers/net/wan/fsl_ucc_hdlc.c static int uhdlc_init(struct ucc_hdlc_private *priv) · line 248
Quoted 9 lines · Rasmus Villemoes
drivers/net/wan/fsl_ucc_hdlc.c +1
-0@@ -245,6 +245,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) ret = -ENOMEM ; goto free_riptr; } +if (riptr != (u16 )riptr || tiptr != (u16 )tiptr) {
"riptr/tiptr > U16_MAX" is clearer.
Re: [PATCH v4 45/47] net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
Quoted 15 lines · Timur Tabi
drivers/net/wan/fsl_ucc_hdlc.c static int uhdlc_init(struct ucc_hdlc_private *priv) · line 248
Quoted 9 lines · Rasmus Villemoes
drivers/net/wan/fsl_ucc_hdlc.c +1
-0@@ -245,6 +245,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) ret = -ENOMEM ; goto free_riptr; } +if (riptr != (u16 )riptr || tiptr != (u16 )tiptr) {"riptr/tiptr >
U16_MAX" is clearer.
I can change it, sure, but it's a matter of taste. To me the above asks "does the value change when it is truncated to a u16" which makes perfect sense when the value is next used with iowrite16be(). Using a comparison to U16_MAX takes more brain cycles for me, because I have to think whether it should be > or >=, and are there some signedness/integer promotion business interfering with that test.
Rasmus
Timur Tabi
maintainerRe: [PATCH v4 45/47] net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
Quoted 6 lines · Rasmus Villemoes
I can change it, sure, but it's a matter of taste. To me the above asks "does the value change when it is truncated to a u16" which makes perfect sense when the value is next used with
iowrite16be(). Using a comparison toU16_MAXtakes more brain cycles for me, because I have to think whether it should be > or >=, and are there some signedness/integer promotion business interfering with that test.
Ok.
PATCH v4 46/47 net: ethernet: freescale: make UCC_GETH explicitly depend on PPC32
In reply to Rasmus VillemoesCurrently, QUICC_ENGINE depends on PPC32, so this in itself does not change anything. In order to allow removing the PPC32 dependency from QUICC_ENGINE and avoid allmodconfig build failures, add this explicit dependency.
--- drivers/net/ethernet/freescale/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/Kconfig +1 -1
@@ -74,7 +74,7 @@ config FSL_XGMAC_MDIO config UCC_GETH tristate "Freescale QE Gigabit Ethernet" - depends on QUICC_ENGINE + depends on QUICC_ENGINE && PPC32 select FSL_PQ_MDIO select PHYLIB ---help---
Signature · 1 line
2.23.0
Timur Tabi
maintainerRe: [PATCH v4 46/47] net: ethernet: freescale: make UCC_GETH explicitly depend on PPC32
Quoted 5 lines · Rasmus Villemoes
Currently,
QUICC_ENGINEdepends on PPC32, so this in itself does not change anything. In order to allow removing the PPC32 dependency fromQUICC_ENGINEand avoid allmodconfig build failures, add this explicit dependency.
Can you add an explanation why we don't want ucc_geth on non-PowerPC platforms?
Re: [PATCH v4 46/47] net: ethernet: freescale: make UCC_GETH explicitly depend on PPC32
Quoted 10 lines · Timur Tabi
Quoted 5 lines · Rasmus Villemoes
Currently,
QUICC_ENGINEdepends on PPC32, so this in itself does not change anything. In order to allow removing the PPC32 dependency fromQUICC_ENGINEand avoid allmodconfig build failures, add this explicit dependency.Can you add an explanation why we don't want
ucc_gethon non-PowerPC platforms?
I think it is because the QE Ethernet was never integrated in any non-PowerPC SoC and most likely will not be in the future. We probably can make it compile for other architectures for general code quality but it is not a priority.
Regards,
Leo
Re: [PATCH v4 46/47] net: ethernet: freescale: make UCC_GETH explicitly depend on PPC32
Quoted 11 lines · Li Yang
Quoted 10 lines · Timur Tabi
Quoted 5 lines · Rasmus Villemoes
Currently,
QUICC_ENGINEdepends on PPC32, so this in itself does not change anything. In order to allow removing the PPC32 dependency fromQUICC_ENGINEand avoid allmodconfig build failures, add this explicit dependency.Can you add an explanation why we don't want
ucc_gethon non-PowerPC platforms?
It's not that "we" don't want to allow building this on non-PPC per se, but making it build requires some surgery that I think should be done by whoever might eventually want it. So _my_ reason for lowering this dependency from QUICC_ENGINE to UCC_GETH is exactly what it says above.
Quoted 2 lines
I think it is because the QE Ethernet was never integrated in any non-PowerPC SoC and most likely will not be in the future.
Well, that kind of thing is impossible to know for outsiders like me. Maybe one can amend the commit log with that info:
"Also, the QE Ethernet has never been integrated on any non-PowerPC SoC and most likely will not be in the future."
Rasmus
Timur Tabi
maintainerRe: [PATCH v4 46/47] net: ethernet: freescale: make UCC_GETH explicitly depend on PPC32
Quoted 2 lines · Rasmus Villemoes
"Also, the QE Ethernet has never been integrated on any non-PowerPC SoC and most likely will not be in the future."
That works for me, thanks.
Timur Tabi
maintainerRe: [PATCH v4 46/47] net: ethernet: freescale: make UCC_GETH explicitly depend on PPC32
In reply to Li YangQuoted 5 lines · Li Yang
Quoted 1 line
Can you add an explanation why we don't want
ucc_gethon non-PowerPC platforms?I think it is because the QE Ethernet was never integrated in any non-PowerPC SoC and most likely will not be in the future. We probably can make it compile for other architectures for general code quality but it is not a priority.
This explanation belongs in the commit message.
PATCH v4 47/47 soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE
In reply to Rasmus VillemoesThere are also ARM and ARM64 based SOCs with a QUICC Engine, and the core QE code as well as net/wan/fsl_ucc_hdlc and tty/serial/ucc_uart has now been modified to not rely on ppcisms.
So extend the architectures that can select QUICC_ENGINE, and add the rather modest requirements of OF && HAS_IOMEM.
The core code as well as the ucc_uart driver has been tested on an LS1021A (arm), and it has also been tested that the QE code still works on an mpc8309 (ppc).
--- drivers/soc/fsl/qe/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/soc/fsl/qe/Kconfig +2 -1
@@ -5,7 +5,8 @@ config QUICC_ENGINE bool "QUICC Engine (QE) framework support" - depends on FSL_SOC && PPC32 + depends on OF && HAS_IOMEM + depends on PPC32 || ARM || ARM64 || COMPILE_TEST select GENERIC_ALLOCATOR select CRC32 help
Signature · 1 line
2.23.0
Re: [PATCH v4 47/47] soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE
Quoted 22 lines · Rasmus Villemoes
There are also ARM and ARM64 based SOCs with a QUICC Engine, and the core QE code as well as
net/wan/fsl_ucc_hdlcand tty/serial/ucc_uart has now been modified to not rely on ppcisms.So extend the architectures that can select
QUICC_ENGINE, and add the rather modest requirements of OF &&HAS_IOMEM.The core code as well as the
ucc_uartdriver has been tested on an LS1021A (arm), and it has also been tested that the QE code still works on an mpc8309 (ppc).Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/soc/fsl/qe/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/soc/fsl/qe/Kconfig +0
-0
drivers/soc/fsl/qe/Kconfig line 9
Quoted 6 lines
drivers/soc/fsl/qe/Kconfig +2
-1@@ -5,7 +5,8 @@ config QUICC_ENGINE bool "QUICC Engine (QE) framework support" - depends on FSL_SOC && PPC32 + depends on OF && HAS_IOMEM + depends on PPC32 || ARM || ARM64 || COMPILE_TEST
Can you also add PPC64? It is also used on some PPC64 platforms (QorIQ T series).
Quoted 6 lines
drivers/soc/fsl/qe/Kconfig +0
-1select GENERIC_ALLOCATOR select CRC32 help --2.23.0
Re: [PATCH v4 47/47] soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE
Quoted 25 lines · Li Yang
Quoted 23 lines · Rasmus Villemoes
There are also ARM and ARM64 based SOCs with a QUICC Engine, and the core QE code as well as
net/wan/fsl_ucc_hdlcand tty/serial/ucc_uart has now been modified to not rely on ppcisms.So extend the architectures that can select
QUICC_ENGINE, and add the rather modest requirements of OF &&HAS_IOMEM.The core code as well as the
ucc_uartdriver has been tested on an LS1021A (arm), and it has also been tested that the QE code still works on an mpc8309 (ppc).Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/soc/fsl/qe/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/soc/fsl/qe/Kconfig +0
-0@@ -5,7 +5,8 @@
Quoted 8 lines
drivers/soc/fsl/qe/Kconfig line 9
Quoted 5 lines
drivers/soc/fsl/qe/Kconfig +2
-1config QUICC_ENGINE bool "QUICC Engine (QE) framework support" - depends on FSL_SOC && PPC32 + depends on OF && HAS_IOMEM + depends on PPC32 || ARM || ARM64 || COMPILE_TESTCan you also add PPC64? It is also used on some PPC64 platforms (QorIQ T series).
Sure, but if that's the only thing in the whole series, perhaps you could amend it when applying instead of me sending all 47 patches again.
Should PPC32 || PPC64 be spelled PPC?
Rasmus
Re: [PATCH v4 47/47] soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE
Quoted 36 lines · Rasmus Villemoes
Quoted 25 lines · Li Yang
Quoted 23 lines · Rasmus Villemoes
There are also ARM and ARM64 based SOCs with a QUICC Engine, and the core QE code as well as
net/wan/fsl_ucc_hdlcand tty/serial/ucc_uart has now been modified to not rely on ppcisms.So extend the architectures that can select
QUICC_ENGINE, and add the rather modest requirements of OF &&HAS_IOMEM.The core code as well as the
ucc_uartdriver has been tested on an LS1021A (arm), and it has also been tested that the QE code still works on an mpc8309 (ppc).Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/soc/fsl/qe/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/soc/fsl/qe/Kconfig +0
-0@@ -5,7 +5,8 @@Quoted 8 lines
drivers/soc/fsl/qe/Kconfig line 9
Quoted 5 lines
drivers/soc/fsl/qe/Kconfig +2
-1config QUICC_ENGINE bool "QUICC Engine (QE) framework support" - depends on FSL_SOC && PPC32 + depends on OF && HAS_IOMEM + depends on PPC32 || ARM || ARM64 || COMPILE_TESTCan you also add PPC64? It is also used on some PPC64 platforms (QorIQ T series).
Quoted 2 lines
Sure, but if that's the only thing in the whole series, perhaps you could amend it when applying instead of me sending all 47 patches again.
Sure. I can do that.
Quoted 2 lines
Should PPC32 || PPC64 be spelled PPC?
Yes. That will be good.
Regards,
Leo
RE: [PATCH v4 47/47] soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE
In reply to Rasmus VillemoesQuoted 32 lines · Rasmus Villemoes
-----Original Message-----
From: Rasmus Villemoes <[email protected]>
Sent: 2019年11月8日 21:01
To: Qiang Zhao <[email protected]>; Leo Li <[email protected]>; Christophe Leroy <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Scott Wood <[email protected]>; Rasmus Villemoes <[email protected]>
Subject: [PATCH v4 47/47] soc: fsl: qe: remove PPC32 dependency fromCONFIG_QUICC_ENGINEThere are also ARM and ARM64 based SOCs with a QUICC Engine, and the core QE code as well as
net/wan/fsl_ucc_hdlcand tty/serial/ucc_uart has now been modified to not rely on ppcisms.So extend the architectures that can select
QUICC_ENGINE, and add the rather modest requirements of OF &&HAS_IOMEM.The core code as well as the
ucc_uartdriver has been tested on an LS1021A (arm), and it has also been tested that the QE code still works on an mpc8309 (ppc).Signed-off-by Rasmus Villemoes <[email protected]>--- drivers/soc/fsl/qe/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/soc/fsl/qe/Kconfig index renamed from drivers/soc/fsl/qe/Kconfig +0
-0
cfa4b2939992..f1974f811572100644
drivers/soc/fsl/qe/Kconfig
Quoted 10 lines
drivers/soc/fsl/qe/Kconfig +2
-2@@ -5,7 +5,8 @@ config QUICC_ENGINE bool "QUICC Engine (QE) framework support" - depends on FSL_SOC && PPC32 + depends on OF && HAS_IOMEM + depends on PPC32 || ARM || ARM64 || COMPILE_TEST select GENERIC_ALLOCATOR select CRC32 help --
Tested QE-HDLC on ARM64!
Best Regards
Qiang Zhao
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
kbuild test robot
build botRe: [PATCH v4 47/47] soc: fsl: qe: remove PPC32 dependency from CONFIG_QUICC_ENGINE
In reply to Rasmus VillemoesThank you for the patch! Yet something to improve:
Hi Rasmus,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net-next/master]
[cannot apply to v5.4-rc8 next-20191120]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Rasmus-Villemoes/soc-fsl-qe-remove-space-before-tab/20191110-050001 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 92da362c07d413786ab59db1665376fb63805586 config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from drivers/soc/fsl/qe/ucc.c:18:0:
>> arch/arm/include/asm/irq.h:34:50: error: unknown type name 'cpumask_t'
extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask,
^~~~~~~~~
vim +/cpumask_t +34 arch/arm/include/asm/irq.h
446616dbb48c7d Russell King 2008-09-06 32 96f0e00378d4a1 Russell King 2014-09-03 33 #ifdef CONFIG_SMP 9a01c3ed5cdb35 Chris Metcalf 2016-10-07 @34 extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, 9a01c3ed5cdb35 Chris Metcalf 2016-10-07 35 bool exclude_self); 9a01c3ed5cdb35 Chris Metcalf 2016-10-07 36 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace 96f0e00378d4a1 Russell King 2014-09-03 37 #endif
96f0e00378d4a1 Russell King 2014-09-03 38
:::::: The code at line 34 was first introduced by commit
:::::: 9a01c3ed5cdb35d9004eb92510ee6ea11b4a5f16 nmi_backtrace: add more trigger_*_cpu_backtrace() methods
:::::: TO: Chris Metcalf <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Quoted 1 line · Rasmus Villemoes
I'm generally ok with these enhencements and cleanups. But as the whole patch series touched multiple subsystems, I would like to collect the Acked-by from Scott, Greg and David if we want the whole series to go through the fsl/soc tree.
Also Qiang, can you help to test the latest version and provide you Tested-by? Thanks.
Quoted 53 lines
There have been several attempts in the past few years to allow building the QUICC engine drivers for platforms other than PPC. This is yet another attempt.
v3 can be found here: https://lore.kernel.org/lkml/[email protected]/
v4 adds a some patches to fix (ab)use of
IS_ERR_VALUEwhich fails when sizeof(u32) != sizeof(long), i.e. on 64-bit platforms. Freescale drivers are some of the last holdouts using that macro (outside ofarch/and core mm code), so I decided trying to simply get rid of it instead of papering over it by using a temporary long to store the result in. Doing that I stumbled on some other things that should be fixed. These are the new patches 34-45.Patch 35 from v3 (which added a PPC32 dependency to
FSL_UCC_HDLC) is gone from this version, so that that driver can indeed now be built for arm and arm64.1-5 are about replacing
in_be32etc. in the core QE code (drivers/soc/fsl/qe).6-8 handle miscellaneous other ppcisms.
9-21 deal with
qe_ic: Simplifying the driver significantly by removing unused code, and removing the platform-specific initialization fromarch/powerpc/.22-25 deal with raw access to devicetree properties in native endianness.
26-33 makes
drivers/tty/serial/ucc_uart.c(CONFIG_SERIAL_QE) ready to build on arm.34-45 deal with
IS_ERR_VALUE()and some other things found while digging around that part of the code.46 adds a PPC32 dependency to
UCC_GETH- it has some of the same issues that have been fixed in theucc_uartanducc_hdlccases. Nobody has requested that I allow that driver to be built for arm{,64}, so instead of growing this series even bigger, I kept that addition. It's trivial to remove if somebody cares enough to fix the build errors/warnings and actually has a platform to test the result on.Finally patch 47 lifts the PPC32 restriction from
QUICC_ENGINE. At the request of Li Yang, it doesn't remove the PPC32 dependency but instead changes it to PPC32 || ARM || ARM64 (orCOMPILE_TEST), i.e. listing the platforms that may have a QE.The series has been built and booted on both an mpc8309-based platform (ppc) as well as an ls1021a-based platform (arm). The core QE code is exercised on both, while I could only test the
ucc_uarton arm, since the uarts are not wired up on our mpc8309 board. Qiang Zhao reports that theucc_hdlcdriver does indeed work on a ls1043ardb (arm64) board, I hope he'll formally add a Tested-by: to the relevant patches since I don't have any arm64 board with QE.
Quoted 15 lines
Rasmus Villemoes (47):
soc: fsl: qe: remove space-before-tab
soc: fsl: qe: drop volatile qualifier of structqe_ic::regs
soc: fsl: qe: rename qe_(clr/set/clrset)bit* helpers
soc: fsl: qe: introduce qe_io{read,write}* wrappers
soc: fsl: qe: avoid ppc-specific io accessors
soc: fsl: qe: replacespin_event_timeoutbyreadx_poll_timeout_atomic
soc: fsl: qe:qe.c: guard use ofpvr_version_is()withCONFIG_PPC32
soc: fsl: qe: drop unneeded #includes
soc: fsl: qe: drop assign-onlyhigh_activeinqe_ic_init
soc: fsl: qe: remove pointless sysfs registration inqe_ic.c
soc: fsl: qe: use qe_ic_cascade_{low,high}_mpic also on 83xx
soc: fsl: qe: move calls ofqe_ic_initout ofarch/powerpc/powerpc/83xx: removempc83xx_ipic_and_qe_init_IRQpowerpc/85xx: remove mostly pointlessmpc85xx_qe_init()
Scott,
What do you think about the PPC changes?
Quoted 11 lines
soc: fsl: qe: move qe_ic_cascade_* functions to
qe_ic.c
soc: fsl: qe: renameqe_ic_cascade_low_mpic->qe_ic_cascade_low
soc: fsl: qe: remove unused qe_ic_set_* functions
soc: fsl: qe: don't useNO_IRQinqe_ic.c
soc: fsl: qe: make qe_ic_get_{low,high}_irq static
soc: fsl: qe: simplifyqe_ic_init()
soc: fsl: qe: mergeqe_ic.hheaders intoqe_ic.c
soc: fsl: qe:qe.c: use of_property_read_* helpers
soc: fsl: qe:qe_io.c: don't open-codeof_parse_phandle()
soc: fsl: qe:qe_io.c: access device tree property usingbe32_to_cpu
soc: fsl: qe:qe_io.c: useof_property_read_u32()inpar_io_init()
Quoted 8 lines
soc: fsl: move
cpm.hfrom powerpc/include/asm toinclude/soc/fslsoc/fsl/qe/qe.h: update include path forcpm.h
serial:ucc_uart: explicitly includesoc/fsl/cpm.h
serial:ucc_uart: replace ppc-specific IO accessors
serial:ucc_uart: factor outsoft_uartinitialization
serial:ucc_uart: stub outsoft_uart_initfor !CONFIG_PPC32
serial:ucc_uart: useof_property_read_u32()inucc_uart_probe()
serial:ucc_uart: access__be32field usingbe32_to_cpu
Greg and Timur,
What do you think about these serial changes.
Quoted 6 lines
soc: fsl: qe: change return type of
cpm_muram_alloc()to s32
soc: fsl: qe: makecpm_muram_free()return void
soc: fsl: qe: makecpm_muram_free()ignore a negative offset
soc: fsl: qe: drop broken lazy call ofcpm_muram_init()
soc: fsl: qe: refactorcpm_muram_alloc_commonto prevent BUG on error
path
Quoted 8 lines
soc: fsl: qe: avoid
IS_ERR_VALUEinucc_slow.c
soc: fsl: qe: drop use ofIS_ERR_VALUEinqe_sdma_init()
soc: fsl: qe: drop pointless check inqe_sdma_init()
soc: fsl: qe: avoidIS_ERR_VALUEinucc_fast.cnet/wan/fsl_ucc_hdlc: avoid use ofIS_ERR_VALUE()net/wan/fsl_ucc_hdlc: fix reading of__be16registersnet/wan/fsl_ucc_hdlc: reject muram offsets above 64K
net: ethernet: freescale: makeUCC_GETHexplicitly depend on PPC32
David and Qiang,
What do you think of the net changes?
Quoted 45 lines
soc: fsl: qe: remove PPC32 dependency from
CONFIG_QUICC_ENGINEarch/powerpc/include/asm/cpm.h | 172 +------- arch/powerpc/platforms/83xx/km83xx.c | 3 +- arch/powerpc/platforms/83xx/misc.c | 23 -- arch/powerpc/platforms/83xx/mpc832x_mds.c | 3 +- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 3 +- arch/powerpc/platforms/83xx/mpc836x_mds.c | 3 +- arch/powerpc/platforms/83xx/mpc836x_rdk.c | 3 +- arch/powerpc/platforms/83xx/mpc83xx.h | 7 - arch/powerpc/platforms/85xx/common.c | 23 -- arch/powerpc/platforms/85xx/corenet_generic.c | 12 - arch/powerpc/platforms/85xx/mpc85xx.h | 2 - arch/powerpc/platforms/85xx/mpc85xx_mds.c | 28 -- arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 18 - arch/powerpc/platforms/85xx/twr_p102x.c | 16 - drivers/net/ethernet/freescale/Kconfig | 2 +- drivers/net/wan/fsl_ucc_hdlc.c | 23 +- drivers/net/wan/fsl_ucc_hdlc.h | 2 +- drivers/soc/fsl/qe/Kconfig | 3 +- drivers/soc/fsl/qe/gpio.c | 34 +- drivers/soc/fsl/qe/qe.c | 104 ++--- drivers/soc/fsl/qe/qe_common.c | 50 +-- drivers/soc/fsl/qe/qe_ic.c | 285 ++++++------- drivers/soc/fsl/qe/qe_ic.h | 99 ----- drivers/soc/fsl/qe/qe_io.c | 70 ++-- drivers/soc/fsl/qe/qe_tdm.c | 8 +- drivers/soc/fsl/qe/ucc.c | 26 +- drivers/soc/fsl/qe/ucc_fast.c | 86 ++-- drivers/soc/fsl/qe/ucc_slow.c | 60 ++- drivers/soc/fsl/qe/usb.c | 2 +- drivers/tty/serial/ucc_uart.c | 383 +++++++++--------- include/soc/fsl/cpm.h | 171 ++++++++ include/soc/fsl/qe/qe.h | 59 ++- include/soc/fsl/qe/qe_ic.h | 135 ------ include/soc/fsl/qe/ucc_fast.h | 4 +- include/soc/fsl/qe/ucc_slow.h | 6 +- 35 files changed, 770 insertions(+), 1158 deletions(-) delete mode 100644 drivers/soc/fsl/qe/qe_ic.h create mode 100644 include/soc/fsl/cpm.h delete mode 100644 include/soc/fsl/qe/qe_ic.h--
2.23.0
Quoted 9 lines · Li Yang
Quoted 1 line · Rasmus Villemoes
I'm generally ok with these enhencements and cleanups. But as the whole patch series touched multiple subsystems, I would like to collect the Acked-by from Scott, Greg and David if we want the whole series to go through the fsl/soc tree.
Rasmus,
Since the patches also touched net and serial subsystem. Can you also repost these patches(maybe just related ones) onto netdev and linux-serial mailing list?
Regards,
Leo
Quoted 162 lines
Also Qiang, can you help to test the latest version and provide you Tested-by? Thanks.
Quoted 53 lines
There have been several attempts in the past few years to allow building the QUICC engine drivers for platforms other than PPC. This is yet another attempt.
v3 can be found here: https://lore.kernel.org/lkml/[email protected]/
v4 adds a some patches to fix (ab)use of
IS_ERR_VALUEwhich fails when sizeof(u32) != sizeof(long), i.e. on 64-bit platforms. Freescale drivers are some of the last holdouts using that macro (outside ofarch/and core mm code), so I decided trying to simply get rid of it instead of papering over it by using a temporary long to store the result in. Doing that I stumbled on some other things that should be fixed. These are the new patches 34-45.Patch 35 from v3 (which added a PPC32 dependency to
FSL_UCC_HDLC) is gone from this version, so that that driver can indeed now be built for arm and arm64.1-5 are about replacing
in_be32etc. in the core QE code (drivers/soc/fsl/qe).6-8 handle miscellaneous other ppcisms.
9-21 deal with
qe_ic: Simplifying the driver significantly by removing unused code, and removing the platform-specific initialization fromarch/powerpc/.22-25 deal with raw access to devicetree properties in native endianness.
26-33 makes
drivers/tty/serial/ucc_uart.c(CONFIG_SERIAL_QE) ready to build on arm.34-45 deal with
IS_ERR_VALUE()and some other things found while digging around that part of the code.46 adds a PPC32 dependency to
UCC_GETH- it has some of the same issues that have been fixed in theucc_uartanducc_hdlccases. Nobody has requested that I allow that driver to be built for arm{,64}, so instead of growing this series even bigger, I kept that addition. It's trivial to remove if somebody cares enough to fix the build errors/warnings and actually has a platform to test the result on.Finally patch 47 lifts the PPC32 restriction from
QUICC_ENGINE. At the request of Li Yang, it doesn't remove the PPC32 dependency but instead changes it to PPC32 || ARM || ARM64 (orCOMPILE_TEST), i.e. listing the platforms that may have a QE.The series has been built and booted on both an mpc8309-based platform (ppc) as well as an ls1021a-based platform (arm). The core QE code is exercised on both, while I could only test the
ucc_uarton arm, since the uarts are not wired up on our mpc8309 board. Qiang Zhao reports that theucc_hdlcdriver does indeed work on a ls1043ardb (arm64) board, I hope he'll formally add a Tested-by: to the relevant patches since I don't have any arm64 board with QE.Quoted 15 lines
Rasmus Villemoes (47):
soc: fsl: qe: remove space-before-tab
soc: fsl: qe: drop volatile qualifier of structqe_ic::regs
soc: fsl: qe: rename qe_(clr/set/clrset)bit* helpers
soc: fsl: qe: introduce qe_io{read,write}* wrappers
soc: fsl: qe: avoid ppc-specific io accessors
soc: fsl: qe: replacespin_event_timeoutbyreadx_poll_timeout_atomic
soc: fsl: qe:qe.c: guard use ofpvr_version_is()withCONFIG_PPC32
soc: fsl: qe: drop unneeded #includes
soc: fsl: qe: drop assign-onlyhigh_activeinqe_ic_init
soc: fsl: qe: remove pointless sysfs registration inqe_ic.c
soc: fsl: qe: use qe_ic_cascade_{low,high}_mpic also on 83xx
soc: fsl: qe: move calls ofqe_ic_initout ofarch/powerpc/powerpc/83xx: removempc83xx_ipic_and_qe_init_IRQpowerpc/85xx: remove mostly pointlessmpc85xx_qe_init()Scott,
What do you think about the PPC changes?Quoted 11 lines
soc: fsl: qe: move qe_ic_cascade_* functions to
qe_ic.c
soc: fsl: qe: renameqe_ic_cascade_low_mpic->qe_ic_cascade_low
soc: fsl: qe: remove unused qe_ic_set_* functions
soc: fsl: qe: don't useNO_IRQinqe_ic.c
soc: fsl: qe: make qe_ic_get_{low,high}_irq static
soc: fsl: qe: simplifyqe_ic_init()
soc: fsl: qe: mergeqe_ic.hheaders intoqe_ic.c
soc: fsl: qe:qe.c: use of_property_read_* helpers
soc: fsl: qe:qe_io.c: don't open-codeof_parse_phandle()
soc: fsl: qe:qe_io.c: access device tree property usingbe32_to_cpu
soc: fsl: qe:qe_io.c: useof_property_read_u32()inpar_io_init()Quoted 8 lines
soc: fsl: move
cpm.hfrom powerpc/include/asm toinclude/soc/fslsoc/fsl/qe/qe.h: update include path forcpm.h
serial:ucc_uart: explicitly includesoc/fsl/cpm.h
serial:ucc_uart: replace ppc-specific IO accessors
serial:ucc_uart: factor outsoft_uartinitialization
serial:ucc_uart: stub outsoft_uart_initfor !CONFIG_PPC32
serial:ucc_uart: useof_property_read_u32()inucc_uart_probe()
serial:ucc_uart: access__be32field usingbe32_to_cpuGreg and Timur,
What do you think about these serial changes.Quoted 6 lines
soc: fsl: qe: change return type of
cpm_muram_alloc()to s32
soc: fsl: qe: makecpm_muram_free()return void
soc: fsl: qe: makecpm_muram_free()ignore a negative offset
soc: fsl: qe: drop broken lazy call ofcpm_muram_init()
soc: fsl: qe: refactorcpm_muram_alloc_commonto prevent BUG on error
pathQuoted 8 lines
soc: fsl: qe: avoid
IS_ERR_VALUEinucc_slow.c
soc: fsl: qe: drop use ofIS_ERR_VALUEinqe_sdma_init()
soc: fsl: qe: drop pointless check inqe_sdma_init()
soc: fsl: qe: avoidIS_ERR_VALUEinucc_fast.cnet/wan/fsl_ucc_hdlc: avoid use ofIS_ERR_VALUE()net/wan/fsl_ucc_hdlc: fix reading of__be16registersnet/wan/fsl_ucc_hdlc: reject muram offsets above 64K
net: ethernet: freescale: makeUCC_GETHexplicitly depend on PPC32David and Qiang,
What do you think of the net changes?Quoted 45 lines
soc: fsl: qe: remove PPC32 dependency from
CONFIG_QUICC_ENGINEarch/powerpc/include/asm/cpm.h | 172 +------- arch/powerpc/platforms/83xx/km83xx.c | 3 +- arch/powerpc/platforms/83xx/misc.c | 23 -- arch/powerpc/platforms/83xx/mpc832x_mds.c | 3 +- arch/powerpc/platforms/83xx/mpc832x_rdb.c | 3 +- arch/powerpc/platforms/83xx/mpc836x_mds.c | 3 +- arch/powerpc/platforms/83xx/mpc836x_rdk.c | 3 +- arch/powerpc/platforms/83xx/mpc83xx.h | 7 - arch/powerpc/platforms/85xx/common.c | 23 -- arch/powerpc/platforms/85xx/corenet_generic.c | 12 - arch/powerpc/platforms/85xx/mpc85xx.h | 2 - arch/powerpc/platforms/85xx/mpc85xx_mds.c | 28 -- arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 18 - arch/powerpc/platforms/85xx/twr_p102x.c | 16 - drivers/net/ethernet/freescale/Kconfig | 2 +- drivers/net/wan/fsl_ucc_hdlc.c | 23 +- drivers/net/wan/fsl_ucc_hdlc.h | 2 +- drivers/soc/fsl/qe/Kconfig | 3 +- drivers/soc/fsl/qe/gpio.c | 34 +- drivers/soc/fsl/qe/qe.c | 104 ++--- drivers/soc/fsl/qe/qe_common.c | 50 +-- drivers/soc/fsl/qe/qe_ic.c | 285 ++++++------- drivers/soc/fsl/qe/qe_ic.h | 99 ----- drivers/soc/fsl/qe/qe_io.c | 70 ++-- drivers/soc/fsl/qe/qe_tdm.c | 8 +- drivers/soc/fsl/qe/ucc.c | 26 +- drivers/soc/fsl/qe/ucc_fast.c | 86 ++-- drivers/soc/fsl/qe/ucc_slow.c | 60 ++- drivers/soc/fsl/qe/usb.c | 2 +- drivers/tty/serial/ucc_uart.c | 383 +++++++++--------- include/soc/fsl/cpm.h | 171 ++++++++ include/soc/fsl/qe/qe.h | 59 ++- include/soc/fsl/qe/qe_ic.h | 135 ------ include/soc/fsl/qe/ucc_fast.h | 4 +- include/soc/fsl/qe/ucc_slow.h | 6 +- 35 files changed, 770 insertions(+), 1158 deletions(-) delete mode 100644 drivers/soc/fsl/qe/qe_ic.h create mode 100644 include/soc/fsl/cpm.h delete mode 100644 include/soc/fsl/qe/qe_ic.h--
2.23.0
Quoted 11 lines · Li Yang
Quoted 9 lines · Li Yang
Quoted 1 line · Rasmus Villemoes
I'm generally ok with these enhencements and cleanups. But as the whole patch series touched multiple subsystems, I would like to collect the Acked-by from Scott, Greg and David if we want the whole series to go through the fsl/soc tree.
Quoted 5 lines
Rasmus,
Since the patches also touched net and serial subsystem. Can you also repost these patches(maybe just related ones) onto netdev and linux-serial mailing list?
They were sent to those lists already. For example, according to
<https://lore.kernel.org/lkml/[email protected]/>,
the recipients for 28/47 were
To: Qiang Zhao <[email protected]>, Li Yang <[email protected]>,
Christophe Leroy <[email protected]>
Cc: [email protected],
[email protected], [email protected], Scott Wood <[email protected]>, Rasmus Villemoes <[email protected]>, [email protected]
same for 29-33, and 43-46 was cc'ed to netdev@.
Rasmus