Skip to contentSkip to conversation

Initial Microchip PIC32MZ[DA] Support

PATCH New Purna Chandra Mandal 3 participants 19 messages Jan 28, 2016 – Feb 1, 2016

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

v4 cover Initial Microchip PIC32MZ[DA] Support

This patch series adds support for Microchip PIC32MZ[DA] MIPS microcontroller platform. All drivers required to boot from MMC uSD card and network are included in it; clock, pinctrl, gpio, DDR2, serial, SDHCI, ethernet.
This series been tested on PIC32MZ[DA] Starter Kit.

This series is generated on u-boot/master branch. A tree with these changes is available at [1].

[1] https://github.com/purna-mandal/u-boot/tree/pic32-upstream-v4
[0] https://github.com/purna-mandal/u-boot/tree/pic32-upstream-v3

Changes in v4:
- update kconfig dependency and default selection
- drop ioremap failure check
- gpio: return -EPERM if the pin is found in analog mode
- gpio: drop desc->offset setting in _gpio_xlate()
- serial: update comment for _pending_input().
- serial: rename UART_RX_OERR to UART_RX_OVER.
- serial: DEBUG_UART_PIC32 now depends on PIC32_SERIAL
- serial: extract clock-id from device-tree
- drop forcing DM_SERIAL, PIC32_SERIAL, PIC32_PINCTRL in mach-pic32/Kconfig
- drop extra includes
- rename clock compatible to "pic32mzda-clk" from "pic32mzda_clk".
- fix typo 'clock-cells' to '#clock-cells'
- create defconfig by 'make savedefconfig'
- drop explicit SYS_BAUDRATE_TABLE in favor of default one
- add CD errata under SDHCI_QUIRK_NO_CD
- eth: drop _dcache_flush/invalidate() helpers for flush/invalidate_dcache_range().

Changes in v3:
- drop empty choice in mach-pic32/Kconfig
- add pic32_get_syscfg_base()
- rename clk-pic32.c to clk_pic32.c
- update clock binding documentation
- replace pic32_ioremap() with ioremap()
- separate MPLL initialization constants
- read register base from device-tree
- add/update comments to explain how pinctrl'r works.
- replace pic32_ioremap() with ioremap().
- add check on dev_get_addr()
- remove ofdata_to_platdata, and replace platdata with priv
- remove special handling of '\r' as being handled by serial-uclass
- remove loop to wait for space in tx buffer before pumping char
- annotating fixed table with const
- fix camel-case in ddr2 timing parameters
- fix cmd index parameter of host_load_cmd().
- fix compilation warning
- drop forcing CONFIG_MIPS_BOOT_* selection in mach-pic32/Kconfig
- indent assembly instructions in delay slot
- made GPIO-nodes child of pinctrl-node in devicetree
- replace pic32_ioremap() with ioremap()
- drop SKIP_LOWLEVEL_INIT, GBL_DATA_OFFSET from config header
- move CMD_MEMTEST, CMD_MEMINFO to defconfig
- increase SYS_MALLOC_F_LEN to 0x600
- use auto-generated defconfig - no hand edit
- remove ofdata_to_platdata, and replace platdata with priv
- replace pic32_ioremap() with ioremap()
- use distro boot commands from config_distro_bootcmd.h
- separate old booting logic as legacy_bootcmd
- merge wrappers with eth operation callbacks
- read phy address from device-tree
- rename functions (e.g. _eth_xyz() with pic32_eth_xyz())

Changes in v2:
- move PIC32 specific headers to arch/mips/mach-pic32/include/mach/
- define register-base as physical address
- drop CONFIG_PIC32_SUPPORTS_FDT_BOOT
- add mpll get clock rate
- add pinconf routine for configuring pin property
- fix missing/corrupted chars during baud rate change
- remove loop until any char is avaialbale in getc()
- move ddr2 initialization from board/microchip/ to drivers/ddr/microchip
- drop board_early_init_f
- use macro LEAF(), END() for lowlevel_init
- move initialization of board_init_f() argument to common start.S
- move initdram() from board/microchip/ to mach-pic32/cpu.c
- remove MIPS virtual address in favor physical one in dts file
- move CONFIG_SYS_TEXT_BASE (from board/*/config.mk) to include/configs/<board>.h
- drop sdhci shared bus configuration (for shared interrupt, clock pins)
- drop shared bus (shared pin selection) configuration.
- replace unbounded loop with wait_for_bit()
- replace register access as readl/writel(base + offset)
- translate (dts provided) physical address to MIPS kseg1 address before use

Andrei Pistirica (1):
drivers: mmc: add driver for Microchip PIC32 SDHCI controller.

Paul Thacker (1):
drivers: serial: add driver for Microchip PIC32 UART controller.

Purna Chandra Mandal (11):
MIPS: initial infrastructure for Microchip PIC32 architecture
drivers: clk: Add clock driver for Microchip PIC32 Microcontroller.
drivers: pinctrl: Add pinctrl driver for Microchip PIC32.
drivers: gpio: add driver for Microchip PIC32 GPIO controller.
drivers: ddr: Add DDR2 SDRAM controller driver for Microchip PIC32.
MIPS: Add support for Microchip PIC32MZ[DA] SoC family.
board: Add Microchip PIC32MZ[DA]-Starter-Kit board.
board: add SDHCI support for PIC32MZDASK board.
drivers: net: phy: add SMSC LAN8740 Phy support.
drivers: net: Add ethernet driver for Microchip PIC32.
board: Enable ethernet, tftpboot support to pic32mzdask board.

 arch/mips/Kconfig                                  |   6 +
 arch/mips/Makefile                                 |   1 +
 arch/mips/dts/Makefile                             |   2 +-
 arch/mips/dts/pic32mzda.dtsi                       | 174 ++++++
 arch/mips/dts/pic32mzda_sk.dts                     |  55 ++
 arch/mips/mach-pic32/Kconfig                       |  35 ++
 arch/mips/mach-pic32/Makefile                      |   7 +
 arch/mips/mach-pic32/cpu.c                         | 156 ++++++
 arch/mips/mach-pic32/include/mach/ddr.h            |  32 ++
 arch/mips/mach-pic32/include/mach/pic32.h          |  79 +++
 arch/mips/mach-pic32/lowlevel_init.S               |  27 +
 arch/mips/mach-pic32/reset.c                       |  36 ++
 board/microchip/pic32mzda/Kconfig                  |  13 +
 board/microchip/pic32mzda/MAINTAINERS              |   6 +
 board/microchip/pic32mzda/Makefile                 |   7 +
 board/microchip/pic32mzda/README                   |  22 +
 board/microchip/pic32mzda/pic32mzda.c              |  31 ++
 configs/pic32mzdask_defconfig                      |  34 ++
 .../clock/microchip,pic32-clock.txt                |  33 ++
 .../serial/microchip,pic32-uart.txt                |   5 +
 drivers/Makefile                                   |   1 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk_pic32.c                            | 433 +++++++++++++++
 drivers/ddr/microchip/Makefile                     |   6 +
 drivers/ddr/microchip/ddr2.c                       | 278 ++++++++++
 drivers/ddr/microchip/ddr2_regs.h                  | 148 +++++
 drivers/ddr/microchip/ddr2_timing.h                |  65 +++
 drivers/gpio/Kconfig                               |   7 +
 drivers/gpio/Makefile                              |   2 +-
 drivers/gpio/pic32_gpio.c                          | 174 ++++++
 drivers/mmc/Kconfig                                |   6 +
 drivers/mmc/Makefile                               |   2 +-
 drivers/mmc/pic32_sdhci.c                          |  58 ++
 drivers/mmc/sdhci.c                                |   7 +
 drivers/net/Kconfig                                |   8 +
 drivers/net/Makefile                               |   1 +
 drivers/net/phy/smsc.c                             |  10 +
 drivers/net/pic32_eth.c                            | 605 +++++++++++++++++++++
 drivers/net/pic32_eth.h                            | 164 ++++++
 drivers/net/pic32_mdio.c                           | 121 +++++
 drivers/pinctrl/Kconfig                            |  10 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl_pic32.c                    | 363 +++++++++++++
 drivers/serial/Kconfig                             |  15 +
 drivers/serial/Makefile                            |   1 +
 drivers/serial/serial_pic32.c                      | 198 +++++++
 include/configs/pic32mzdask.h                      | 168 ++++++
 include/dt-bindings/clock/microchip,clock.h        |  29 +
 48 files changed, 3640 insertions(+), 3 deletions(-)
 create mode 100644 arch/mips/dts/pic32mzda.dtsi
 create mode 100644 arch/mips/dts/pic32mzda_sk.dts
 create mode 100644 arch/mips/mach-pic32/Kconfig
 create mode 100644 arch/mips/mach-pic32/Makefile
 create mode 100644 arch/mips/mach-pic32/cpu.c
 create mode 100644 arch/mips/mach-pic32/include/mach/ddr.h
 create mode 100644 arch/mips/mach-pic32/include/mach/pic32.h
 create mode 100644 arch/mips/mach-pic32/lowlevel_init.S
 create mode 100644 arch/mips/mach-pic32/reset.c
 create mode 100644 board/microchip/pic32mzda/Kconfig
 create mode 100644 board/microchip/pic32mzda/MAINTAINERS
 create mode 100644 board/microchip/pic32mzda/Makefile
 create mode 100644 board/microchip/pic32mzda/README
 create mode 100644 board/microchip/pic32mzda/pic32mzda.c
 create mode 100644 configs/pic32mzdask_defconfig
 create mode 100644 doc/device-tree-bindings/clock/microchip,pic32-clock.txt
 create mode 100644 doc/device-tree-bindings/serial/microchip,pic32-uart.txt
 create mode 100644 drivers/clk/clk_pic32.c
 create mode 100644 drivers/ddr/microchip/Makefile
 create mode 100644 drivers/ddr/microchip/ddr2.c
 create mode 100644 drivers/ddr/microchip/ddr2_regs.h
 create mode 100644 drivers/ddr/microchip/ddr2_timing.h
 create mode 100644 drivers/gpio/pic32_gpio.c
 create mode 100644 drivers/mmc/pic32_sdhci.c
 create mode 100644 drivers/net/pic32_eth.c
 create mode 100644 drivers/net/pic32_eth.h
 create mode 100644 drivers/net/pic32_mdio.c
 create mode 100644 drivers/pinctrl/pinctrl_pic32.c
 create mode 100644 drivers/serial/serial_pic32.c
 create mode 100644 include/configs/pic32mzdask.h
 create mode 100644 include/dt-bindings/clock/microchip,clock.h
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v4 1/13 MIPS: initial infrastructure for Microchip PIC32 architecture

Create initial directory, Kconfigs needed for PIC32 architecture support. Also add PIC32 specific register definition required for drivers.

---

Changes in v4: None
Changes in v3:
- drop empty choice in mach-pic32/Kconfig
- add pic32_get_syscfg_base()

Changes in v2:
- move PIC32 specific headers to arch/mips/mach-pic32/include/mach/
- define register-base as physical address
- drop CONFIG_PIC32_SUPPORTS_FDT_BOOT

 arch/mips/Kconfig                         |  6 +++
 arch/mips/Makefile                        |  1 +
 arch/mips/mach-pic32/Kconfig              |  7 +++
 arch/mips/mach-pic32/Makefile             |  7 +++
 arch/mips/mach-pic32/cpu.c                | 13 ++++++
 arch/mips/mach-pic32/include/mach/pic32.h | 76 +++++++++++++++++++++++++++++++
 6 files changed, 110 insertions(+)
 create mode 100644 arch/mips/mach-pic32/Kconfig
 create mode 100644 arch/mips/mach-pic32/Makefile
 create mode 100644 arch/mips/mach-pic32/cpu.c
 create mode 100644 arch/mips/mach-pic32/include/mach/pic32.h
arch/mips/Kconfig +6 -0
index 1b39c4c..380ed81 100644
@@ -54,6 +54,11 @@ config TARGET_PB1X00
 	select SYS_MIPS_CACHE_INIT_RAM_LOAD
 	select MIPS_TUNE_4KC
 
+config MACH_PIC32
+	bool "Support Microchip PIC32"
+	select OF_CONTROL
+	select DM
+
 endchoice
 
 source "board/dbau1x00/Kconfig"
@@ -61,6 +66,7 @@ source "board/imgtec/malta/Kconfig"
 source "board/micronas/vct/Kconfig"
 source "board/pb1x00/Kconfig"
 source "board/qemu-mips/Kconfig"
+source "arch/mips/mach-pic32/Kconfig"
 
 if MIPS
 
arch/mips/Makefile +1 -0
index 2133e7e..aec5a15 100644
@@ -8,6 +8,7 @@ libs-y += arch/mips/cpu/
 libs-y += arch/mips/lib/
 
 machine-$(CONFIG_SOC_AU1X00) += au1x00
+machine-$(CONFIG_MACH_PIC32) += pic32
 
 machdirs := $(patsubst %,arch/mips/mach-%/,$(machine-y))
 libs-y += $(machdirs)
arch/mips/mach-pic32/Kconfig new file +7 -0
new file mode 100644
index 0000000..c1cc5e3
@@ -0,0 +1,7 @@
+menu "Microchip PIC32 platforms"
+	depends on MACH_PIC32
+
+config SYS_SOC
+	default "none"
+
+endmenu
arch/mips/mach-pic32/Makefile new file +7 -0
new file mode 100644
index 0000000..cb42607
@@ -0,0 +1,7 @@
+# (C) Copyright 2015
+# Purna Chandra Mandal, purna.mandal at microchip.com.
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+
+obj-y = cpu.o
arch/mips/mach-pic32/cpu.c new file +13 -0
new file mode 100644
index 0000000..58fd3ab
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2015
+ * Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+#include <common.h>
+
+phys_size_t initdram(int board_type)
+{
+	return 0;
+}
arch/mips/mach-pic32/include/mach/pic32.h new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v4 2/13 drivers: clk: Add clock driver for Microchip PIC32 Microcontroller.

In reply to Purna Chandra Mandal

PIC32 clock module consists of multiple oscillators, PLLs, mutiplexers and dividers capable of supplying clock to various controllers on or off-chip.

---

Changes in v4: None
Changes in v3:
- rename clk-pic32.c to clk_pic32.c
- update clock binding documentation
- replace pic32_ioremap() with ioremap()
- separate MPLL initialization constants

Changes in v2:
- add mpll get clock rate

 .../clock/microchip,pic32-clock.txt                |  33 ++
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk_pic32.c                            | 433 +++++++++++++++++++++
 include/dt-bindings/clock/microchip,clock.h        |  29 ++
 4 files changed, 496 insertions(+)
 create mode 100644 doc/device-tree-bindings/clock/microchip,pic32-clock.txt
 create mode 100644 drivers/clk/clk_pic32.c
 create mode 100644 include/dt-bindings/clock/microchip,clock.h
doc/device-tree-bindings/clock/microchip,pic32-clock.txt new file +33 -0
new file mode 100644
index 0000000..f185ce0
@@ -0,0 +1,33 @@
+* Microchip PIC32 Clock and Oscillator
+
+Microchip PIC32 clock tree consists of few oscillators, PLLs,
+multiplexers and few divider modules capable of supplying clocks
+to various controllers within SoC and also to off-chip.
+
+PIC32 clock controller output is defined by indices as defined
+in [0]
+
+[0] include/dt-bindings/clock/microchip,clock.h
+
+Required Properties:
+- compatible: should be "microchip,pic32mzda_clk"
+- reg: physical base address of the controller and length of memory mapped
+       region.
+- #clock-cells: should be 1.
+
+Example: Clock controller node:
+
+	clock: clk at 1f801200 {
+		compatible = "microchip,pic32mzda-clk";
+		reg = <0x1f801200 0x1000>;
+	};
+
+Example: UART controller node that consumes the clock generated by the clock
+controller:
+
+	uart1: serial at 1f822000 {
+		compatible = "microchip,pic32mzda-uart";
+		reg = <0xbf822000 0x50>;
+		interrupts = <112 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock PB2CLK>;
+	};
drivers/clk/Makefile +1 -0
index 8aa81f4..c9144e3 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_CLK) += clk-uclass.o clk_fixed_rate.o
 obj-$(CONFIG_ROCKCHIP_RK3036) += clk_rk3036.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += clk_rk3288.o
 obj-$(CONFIG_SANDBOX) += clk_sandbox.o
+obj-$(CONFIG_MACH_PIC32) += clk_pic32.o
drivers/clk/clk_pic32.c new file +433 -0

433 lines not on this page · raw message

include/dt-bindings/clock/microchip,clock.h new file +29 -0
new file mode 100644
index 0000000..93c222d
@@ -0,0 +1,29 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#ifndef __CLK_MICROCHIP_PIC32
+#define __CLK_MICROCHIP_PIC32
+
+/* clock output indices */
+#define BASECLK	0
+#define PLLCLK	1
+#define MPLL	2
+#define SYSCLK	3
+#define PB1CLK	4
+#define PB2CLK	5
+#define PB3CLK	6
+#define PB4CLK	7
+#define PB5CLK	8
+#define PB6CLK	9
+#define PB7CLK	10
+#define REF1CLK	11
+#define REF2CLK	12
+#define REF3CLK	13
+#define REF4CLK	14
+#define REF5CLK	15
+
+#endif	/* __CLK_MICROCHIP_PIC32 */
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH v4 3/13 drivers: pinctrl: Add pinctrl driver for Microchip PIC32.

In reply to Purna Chandra Mandal

In PIC32 pin-controller is a combined gpio-controller, pin-mux and pin-config module. Remappable peripherals are assigned pins through per-pin based muxing logic. And pin configuration are performed on specific port registers which are shared along with gpio controller. Note, non-remappable peripherals have default pins assigned thus require no muxing.

---

Changes in v4:
- update commit message
- update kconfig dependency on (DM && MACH_PIC32) and default y

Changes in v3:
- read register base from device-tree
- add/update comments to explain how pinctrl'r works.
- replace pic32_ioremap() with ioremap().

Changes in v2:
- add pinconf routine for configuring pin property

 drivers/pinctrl/Kconfig         |  10 ++
 drivers/pinctrl/Makefile        |   1 +
 drivers/pinctrl/pinctrl_pic32.c | 363 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 374 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl_pic32.c
drivers/pinctrl/Kconfig +10 -0
index 57e6142..5dd2ddd 100644
@@ -131,6 +131,16 @@ config PINCTRL_SANDBOX
 	  actually does nothing but print debug messages when pinctrl
 	  operations are invoked.
 
+config PIC32_PINCTRL
+	bool "Microchip PIC32 pin-control and pin-mux driver"
+	depends on DM && MACH_PIC32
+	default y
+	help
+	  Supports individual pin selection and configuration for each remappable
+	  peripheral available on Microchip PIC32 SoCs. This driver is controlled
+	  by a device tree node which contains both GPIO defintion and pin control
+	  functions.
+
 endif
 
 source "drivers/pinctrl/uniphier/Kconfig"
drivers/pinctrl/Makefile +1 -0
index 70d25dc..b4f4650 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
 obj-$(CONFIG_PINCTRL_SANDBOX)	+= pinctrl-sandbox.o
 
 obj-$(CONFIG_ARCH_UNIPHIER)	+= uniphier/
+obj-$(CONFIG_PIC32_PINCTRL)	+= pinctrl_pic32.o
drivers/pinctrl/pinctrl_pic32.c new file +363 -0

363 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v4 4/13 drivers: gpio: add driver for Microchip PIC32 GPIO controller.

In reply to Purna Chandra Mandal

In PIC32 GPIO controller is part of PIC32 pin controller.
PIC32 has ten independently programmable ports and each with multiple pins. Each of these pins can be configured and used as GPIO, provided they are not in use for other peripherals.

---

Changes in v4:
- update kconfig dependency on DM && MACH_PIC32, and default y
- drop ioremap failure check
- return -EPERM if the pin is found in analog mode
- drop desc->offset setting in _gpio_xlate()

Changes in v3:
- add check on dev_get_addr()

Changes in v2: None

 drivers/gpio/Kconfig      |   7 ++
 drivers/gpio/Makefile     |   2 +-
 drivers/gpio/pic32_gpio.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpio/pic32_gpio.c
drivers/gpio/Kconfig +7 -0
index e60e9fd..845dc72 100644
@@ -83,4 +83,11 @@ config VYBRID_GPIO
 	help
 	  Say yes here to support Vybrid vf610 GPIOs.
 
+config PIC32_GPIO
+	bool "Microchip PIC32 GPIO driver"
+	depends on DM_GPIO && MACH_PIC32
+	default y
+	help
+	  Say yes here to support Microchip PIC32 GPIOs.
+
 endmenu
drivers/gpio/Makefile +1 -1
index fb4fd25..845a6d4 100644
@@ -46,4 +46,4 @@ obj-$(CONFIG_STM32_GPIO)	+= stm32_gpio.o
 obj-$(CONFIG_ZYNQ_GPIO)		+= zynq_gpio.o
 obj-$(CONFIG_VYBRID_GPIO)	+= vybrid_gpio.o
 obj-$(CONFIG_HIKEY_GPIO)	+= hi6220_gpio.o
-
+obj-$(CONFIG_PIC32_GPIO)	+= pic32_gpio.o
drivers/gpio/pic32_gpio.c new file +174 -0

174 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v4 5/13 drivers: serial: add driver for Microchip PIC32 UART controller.

In reply to Purna Chandra Mandal

From: Paul Thacker <[email protected]>

This adds PIC32 UART controller support based on driver model.

---

Changes in v4:
- update kconfig dependency (DM_SERIAL && MACH_PIC32)
- update comment for _pending_input().
- rename UART_RX_OERR to UART_RX_OVER.
- DEBUG_UART_PIC32 now depends on PIC32_SERIAL
- extract clk_id from device-tree

Changes in v3:
- remove ofdata_to_platdata, and replace platdata with priv
- remove special handling of '\r' as being handled by serial-uclass
- remove loop to wait for space in tx buffer before pumping char

Changes in v2:
- fix missing/corrupted chars during baud rate change
- remove loop until any char is avaialbale in getc()

 .../serial/microchip,pic32-uart.txt                |   5 +
 drivers/serial/Kconfig                             |  15 ++
 drivers/serial/Makefile                            |   1 +
 drivers/serial/serial_pic32.c                      | 198 +++++++++++++++++++++
 4 files changed, 219 insertions(+)
 create mode 100644 doc/device-tree-bindings/serial/microchip,pic32-uart.txt
 create mode 100644 drivers/serial/serial_pic32.c
doc/device-tree-bindings/serial/microchip,pic32-uart.txt new file +5 -0
new file mode 100644
index 0000000..f00e215
@@ -0,0 +1,5 @@
+* Microchip PIC32 serial UART
+
+Required properties:
+- compatible: must be "microchip,pic32mzda-uart".
+- reg: exactly one register range.
drivers/serial/Kconfig +15 -0
index 83068cf..43b2ec3 100644
@@ -143,6 +143,14 @@ config DEBUG_UART_PL011
 	  work. The driver will be available until the real driver model
 	  serial is running.
 
+config DEBUG_UART_PIC32
+	bool "Microchip PIC32"
+	depends on PIC32_SERIAL
+	help
+	  Select this to enable a debug UART using the serial_pic32 driver. You
+	  will need to provide parameters to make this work. The driver will
+	  be available until the real driver model serial is running.
+
 endchoice
 
 config DEBUG_UART_BASE
@@ -234,6 +242,13 @@ config FSL_LPUART
 	  Select this to enable a Low Power UART for Freescale VF610 and
 	  QorIQ Layerscape devices.
 
+config PIC32_SERIAL
+	bool "Support for Microchip PIC32 on-chip UART"
+	depends on DM_SERIAL && MACH_PIC32
+	default y
+	help
+	  Support for the UART found on Microchip PIC32 SoC's.
+
 config SYS_NS16550
 	bool "NS16550 UART or compatible"
 	help
drivers/serial/Makefile +1 -0
index dd87147..57cd38b 100644
@@ -41,6 +41,7 @@ obj-$(CONFIG_MXS_AUART) += mxs_auart.o
 obj-$(CONFIG_ARC_SERIAL) += serial_arc.o
 obj-$(CONFIG_UNIPHIER_SERIAL) += serial_uniphier.o
 obj-$(CONFIG_STM32_SERIAL) += serial_stm32.o
+obj-$(CONFIG_PIC32_SERIAL) += serial_pic32.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
drivers/serial/serial_pic32.c new file +198 -0

198 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#6 lore raw

PATCH v4 6/13 drivers: ddr: Add DDR2 SDRAM controller driver for Microchip PIC32.

In reply to Purna Chandra Mandal

This driver initializes PIC32 DDR2 SDRAM controller and internal DDR2 Phy module. DDR2 controller operates in half-rate mode (upto 533MHZ frequency).

---

Changes in v4: None
Changes in v3:
- annotating fixed table with const
- fix camel-case in ddr2 timing parameters
- fix cmd index parameter of host_load_cmd().
- fix compilation warning

Changes in v2:
- move ddr2 initialization from board/microchip/ to drivers/ddr/microchip

 arch/mips/mach-pic32/include/mach/ddr.h |  32 ++++
 drivers/Makefile                        |   1 +
 drivers/ddr/microchip/Makefile          |   6 +
 drivers/ddr/microchip/ddr2.c            | 278 ++++++++++++++++++++++++++++++++
 drivers/ddr/microchip/ddr2_regs.h       | 148 +++++++++++++++++
 drivers/ddr/microchip/ddr2_timing.h     |  65 ++++++++
 6 files changed, 530 insertions(+)
 create mode 100644 arch/mips/mach-pic32/include/mach/ddr.h
 create mode 100644 drivers/ddr/microchip/Makefile
 create mode 100644 drivers/ddr/microchip/ddr2.c
 create mode 100644 drivers/ddr/microchip/ddr2_regs.h
 create mode 100644 drivers/ddr/microchip/ddr2_timing.h
arch/mips/mach-pic32/include/mach/ddr.h new file +32 -0
new file mode 100644
index 0000000..00abfa3
@@ -0,0 +1,32 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#ifndef __MICROCHIP_PIC32_DDR_H
+#define __MICROCHIP_PIC32_DDR_H
+
+/* called by initdram() function */
+void ddr2_phy_init(void);
+void ddr2_ctrl_init(void);
+phys_size_t ddr2_calculate_size(void);
+
+/* Maximum number of agents */
+#define NUM_AGENTS		5
+
+/* Board can provide agent specific parameters for arbitration by
+ * filling struct ddr2_arbiter_params for all the agents and
+ * implementing board_get_ddr_arbiter_params() to return the filled
+ * structure.
+ */
+struct ddr2_arbiter_params {
+	u32 min_limit;	/* min bursts to execute per arbitration */
+	u32 req_period; /* request period threshold for accepted cmds */
+	u32 min_cmd_acpt; /* min number of accepted cmds */
+};
+
+const struct ddr2_arbiter_params *board_get_ddr_arbiter_params(void);
+
+#endif /* __MICROCHIP_PIC32_DDR_H */
drivers/Makefile +1 -0
index 6294048..e7eab66 100644
@@ -69,4 +69,5 @@ obj-y += soc/
 obj-$(CONFIG_REMOTEPROC) += remoteproc/
 obj-y += thermal/
 
+obj-$(CONFIG_MACH_PIC32) += ddr/microchip/
 endif
drivers/ddr/microchip/Makefile new file +6 -0
new file mode 100644
index 0000000..305c48b
@@ -0,0 +1,6 @@
+#
+# Copyright (C) 2015 Microchip Technology Inc.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+obj-$(CONFIG_MACH_PIC32) += ddr2.o
drivers/ddr/microchip/ddr2.c new file +278 -0

278 lines not on this page · raw message

drivers/ddr/microchip/ddr2_regs.h new file +148 -0

148 lines not on this page · raw message

drivers/ddr/microchip/ddr2_timing.h new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#7 lore raw

PATCH v4 7/13 MIPS: Add support for Microchip PIC32MZ[DA] SoC family.

In reply to Purna Chandra Mandal

Add Microchip PIC32MZ[DA] SoC family support.

---

Changes in v4:
- drop forcing DM_SERIAL, PIC32_SERIAL, PIC32_PINCTRL in mach-pic32/Kconfig
- drop extra include
- rename clock compatible to "pic32mzda-clk" from "pic32mzda_clk".
- fix typo 'clock-cells' to '#clock-cells'

Changes in v3:
- drop forcing CONFIG_MIPS_BOOT_* selection in mach-pic32/Kconfig
- indent assembly instructions in delay slot
- made GPIO-nodes child of pinctrl-node in devicetree
- replace pic32_ioremap() with ioremap()

Changes in v2:
- drop board_early_init_f
- use macro LEAF(), END() for lowlevel_init
- move initialization of board_init_f() argument to common start.S
- move initdram() from board/microchip/ to mach-pic32/cpu.c
- remove MIPS virtual address in favor physical one in dts file

 arch/mips/dts/pic32mzda.dtsi              | 153 ++++++++++++++++++++++++++++++
 arch/mips/mach-pic32/Kconfig              |  17 +++-
 arch/mips/mach-pic32/Makefile             |   2 +-
 arch/mips/mach-pic32/cpu.c                | 143 ++++++++++++++++++++++++++++
 arch/mips/mach-pic32/include/mach/pic32.h |   3 +
 arch/mips/mach-pic32/lowlevel_init.S      |  27 ++++++
 arch/mips/mach-pic32/reset.c              |  36 +++++++
 7 files changed, 379 insertions(+), 2 deletions(-)
 create mode 100644 arch/mips/dts/pic32mzda.dtsi
 create mode 100644 arch/mips/mach-pic32/lowlevel_init.S
 create mode 100644 arch/mips/mach-pic32/reset.c
arch/mips/dts/pic32mzda.dtsi new file +153 -0
new file mode 100644
index 0000000..c67cfa9
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2015 Microchip Technology, Inc.
+ * Purna Chandra Mandal, <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/clock/microchip,clock.h>
+#include <dt-bindings/gpio/gpio.h>
+#include "skeleton.dtsi"
+
+/ {
+	compatible = "microchip,pic32mzda", "microchip,pic32mz";
+
+	aliases {
+		gpio0 = &gpioA;
+		gpio1 = &gpioB;
+		gpio2 = &gpioC;
+		gpio3 = &gpioD;
+		gpio4 = &gpioE;
+		gpio5 = &gpioF;
+		gpio6 = &gpioG;
+		gpio7 = &gpioH;
+		gpio8 = &gpioJ;
+		gpio9 = &gpioK;
+	};
+
+	cpus {
+		cpu at 0 {
+			compatible = "mips,mips14kc";
+		};
+	};
+
+	clock: clk at 1f801200 {
+		compatible = "microchip,pic32mzda-clk";
+		reg = <0x1f801200 0x1000>;
+		#clock-cells = <1>;
+	};
+
+	uart1: serial at 1f822000 {
+		compatible = "microchip,pic32mzda-uart";
+		reg = <0x1f822000 0x50>;
+		interrupts = <112 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+		clocks = <&clock PB2CLK>;
+	};
+
+	uart2: serial at 1f822200 {
+		compatible = "microchip,pic32mzda-uart";
+		reg = <0x1f822200 0x50>;
+		interrupts = <145 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock PB2CLK>;
+		status = "disabled";
+	};
+
+	uart6: serial at 1f822a00 {
+		compatible = "microchip,pic32mzda-uart";
+		reg = <0x1f822a00 0x50>;
+		interrupts = <188 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock PB2CLK>;
+		status = "disabled";
+	};
+
+	evic: interrupt-controller at 1f810000 {
+		compatible = "microchip,pic32mzda-evic";
+		interrupt-controller;
+		#interrupt-cells = <2>;
+		reg = <0x1f810000 0x1000>;
+	};
+
+	pinctrl: pinctrl at 1f801400 {
+		compatible = "microchip,pic32mzda-pinctrl";
+		reg = <0x1f801400 0x100>, /* in  */
+		      <0x1f801500 0x200>, /* out */
+		      <0x1f860000 0xa00>; /* port */
+		reg-names = "ppsin","ppsout","port";
+		status = "disabled";
+
+		ranges = <0 0x1f860000 0xa00>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		gpioA: gpio0 at 0 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x000 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioB: gpio1 at 100 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x100 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioC: gpio2 at 200 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x200 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioD: gpio3 at 300 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x300 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioE: gpio4 at 400 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x400 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioF: gpio5 at 500 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x500 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioG: gpio6 at 600 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x600 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioH: gpio7 at 700 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x700 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioJ: gpio8 at 800 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x800 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioK: gpio9 at 900 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x900 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+	};
+};
arch/mips/mach-pic32/Kconfig +16 -1
index c1cc5e3..f636266 100644
@@ -2,6 +2,21 @@ menu "Microchip PIC32 platforms"
 	depends on MACH_PIC32
 
 config SYS_SOC
-	default "none"
+	default "pic32mzda" if SOC_PIC32MZDA
+
+choice
+	prompt "PIC32 SoC select"
+
+config SOC_PIC32MZDA
+	bool "Microchip PIC32MZ[DA] family"
+	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORTS_CPU_MIPS32_R1
+	select SUPPORTS_CPU_MIPS32_R2
+	select MIPS_L1_CACHE_SHIFT_4
+	select SYS_MIPS_CACHE_INIT_RAM_LOAD
+	help
+	  This supports Microchip PIC32MZ[DA] family of microcontrollers.
+
+endchoice
 
 endmenu
arch/mips/mach-pic32/Makefile +1 -1
index cb42607..e321e65 100644
@@ -4,4 +4,4 @@
 # SPDX-License-Identifier:      GPL-2.0+
 #
 
-obj-y = cpu.o
+obj-y = cpu.o lowlevel_init.o reset.o
\ No newline at end of file
arch/mips/mach-pic32/cpu.c +143 -0

151 lines not on this page · raw message

arch/mips/mach-pic32/include/mach/pic32.h +3 -0
index 7e41810..16bfacf 100644
@@ -73,4 +73,7 @@ static inline void __iomem *pic32_get_syscfg_base(void)
 	return (void __iomem *)CKSEG1ADDR(PIC32_CFG_BASE);
 }
 
+/* Core */
+const char *get_core_name(void);
+
 #endif	/* __PIC32_REGS_H__ */
arch/mips/mach-pic32/lowlevel_init.S new file +27 -0
new file mode 100644
index 0000000..e37bebb
@@ -0,0 +1,27 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+*/
+
+#include <config.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/asm.h>
+
+LEAF(lowlevel_init)
+	/*
+	 * Establish Cause
+	 * (set IV bit)
+	 */
+	li	t1, 0x00800000
+	mtc0	t1, CP0_CAUSE
+
+	/* Establish Wired (and Random) */
+	mtc0	zero, CP0_WIRED
+	 nop
+
+	jr	ra
+	 nop
+	END(lowlevel_init)
arch/mips/mach-pic32/reset.c new file +36 -0
new file mode 100644
index 0000000..66c6833
@@ -0,0 +1,36 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <mach/pic32.h>
+
+/* SYSKEY */
+#define UNLOCK_KEY1	0xaa996655
+#define UNLOCK_KEY2	0x556699aa
+#define LOCK_KEY	0
+
+#define RSWRST          0x1250
+
+void _machine_restart(void)
+{
+	void __iomem *base;
+
+	base = pic32_get_syscfg_base();
+
+	/* unlock sequence */
+	writel(LOCK_KEY, base + SYSKEY);
+	writel(UNLOCK_KEY1, base + SYSKEY);
+	writel(UNLOCK_KEY2, base + SYSKEY);
+
+	/* soft reset */
+	writel(0x1, base + RSWRST);
+	(void) readl(base + RSWRST);
+
+	while (1)
+		;
+}
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH v4 7/13 MIPS: Add support for Microchip PIC32MZ[DA] SoC family.

Am 28.01.2016 um 11:00 schrieb Purna Chandra Mandal:

Quoted 3 lines

Add Microchip PIC32MZ[DA] SoC family support.

Quoted 475 lines

---

Changes in v4:
- drop forcing DM_SERIAL, PIC32_SERIAL, PIC32_PINCTRL in mach-pic32/Kconfig
- drop extra include
- rename clock compatible to "pic32mzda-clk" from "pic32mzda_clk".
- fix typo 'clock-cells' to '#clock-cells'

Changes in v3:
- drop forcing CONFIG_MIPS_BOOT_* selection in mach-pic32/Kconfig
- indent assembly instructions in delay slot
- made GPIO-nodes child of pinctrl-node in devicetree
- replace pic32_ioremap() with ioremap()

Changes in v2:
- drop board_early_init_f
- use macro LEAF(), END() for lowlevel_init
- move initialization of board_init_f() argument to common start.S
- move initdram() from board/microchip/ to mach-pic32/cpu.c
- remove MIPS virtual address in favor physical one in dts file

 arch/mips/dts/pic32mzda.dtsi              | 153 ++++++++++++++++++++++++++++++
 arch/mips/mach-pic32/Kconfig              |  17 +++-
 arch/mips/mach-pic32/Makefile             |   2 +-
 arch/mips/mach-pic32/cpu.c                | 143 ++++++++++++++++++++++++++++
 arch/mips/mach-pic32/include/mach/pic32.h |   3 +
 arch/mips/mach-pic32/lowlevel_init.S      |  27 ++++++
 arch/mips/mach-pic32/reset.c              |  36 +++++++
 7 files changed, 379 insertions(+), 2 deletions(-)
 create mode 100644 arch/mips/dts/pic32mzda.dtsi
 create mode 100644 arch/mips/mach-pic32/lowlevel_init.S
 create mode 100644 arch/mips/mach-pic32/reset.c
arch/mips/dts/pic32mzda.dtsi new file +153 -0
new file mode 100644
index 0000000..c67cfa9
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2015 Microchip Technology, Inc.
+ * Purna Chandra Mandal, <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/clock/microchip,clock.h>
+#include <dt-bindings/gpio/gpio.h>
+#include "skeleton.dtsi"
+
+/ {
+	compatible = "microchip,pic32mzda", "microchip,pic32mz";
+
+	aliases {
+		gpio0 = &gpioA;
+		gpio1 = &gpioB;
+		gpio2 = &gpioC;
+		gpio3 = &gpioD;
+		gpio4 = &gpioE;
+		gpio5 = &gpioF;
+		gpio6 = &gpioG;
+		gpio7 = &gpioH;
+		gpio8 = &gpioJ;
+		gpio9 = &gpioK;
+	};
+
+	cpus {
+		cpu at 0 {
+			compatible = "mips,mips14kc";
+		};
+	};
+
+	clock: clk at 1f801200 {
+		compatible = "microchip,pic32mzda-clk";
+		reg = <0x1f801200 0x1000>;
+		#clock-cells = <1>;
+	};
+
+	uart1: serial at 1f822000 {
+		compatible = "microchip,pic32mzda-uart";
+		reg = <0x1f822000 0x50>;
+		interrupts = <112 IRQ_TYPE_LEVEL_HIGH>;
+		status = "disabled";
+		clocks = <&clock PB2CLK>;
+	};
+
+	uart2: serial at 1f822200 {
+		compatible = "microchip,pic32mzda-uart";
+		reg = <0x1f822200 0x50>;
+		interrupts = <145 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock PB2CLK>;
+		status = "disabled";
+	};
+
+	uart6: serial at 1f822a00 {
+		compatible = "microchip,pic32mzda-uart";
+		reg = <0x1f822a00 0x50>;
+		interrupts = <188 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock PB2CLK>;
+		status = "disabled";
+	};
+
+	evic: interrupt-controller at 1f810000 {
+		compatible = "microchip,pic32mzda-evic";
+		interrupt-controller;
+		#interrupt-cells = <2>;
+		reg = <0x1f810000 0x1000>;
+	};
+
+	pinctrl: pinctrl at 1f801400 {
+		compatible = "microchip,pic32mzda-pinctrl";
+		reg = <0x1f801400 0x100>, /* in  */
+		      <0x1f801500 0x200>, /* out */
+		      <0x1f860000 0xa00>; /* port */
+		reg-names = "ppsin","ppsout","port";
+		status = "disabled";
+
+		ranges = <0 0x1f860000 0xa00>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		gpioA: gpio0 at 0 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x000 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioB: gpio1 at 100 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x100 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioC: gpio2 at 200 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x200 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioD: gpio3 at 300 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x300 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioE: gpio4 at 400 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x400 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioF: gpio5 at 500 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x500 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioG: gpio6 at 600 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x600 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioH: gpio7 at 700 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x700 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioJ: gpio8 at 800 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x800 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpioK: gpio9 at 900 {
+			compatible = "microchip,pic32mzda-gpio";
+			reg = <0x900 0x48>;
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+	};
+};
arch/mips/mach-pic32/Kconfig +16 -1
index c1cc5e3..f636266 100644
@@ -2,6 +2,21 @@ menu "Microchip PIC32 platforms"
 	depends on MACH_PIC32
 
 config SYS_SOC
-	default "none"
+	default "pic32mzda" if SOC_PIC32MZDA
+
+choice
+	prompt "PIC32 SoC select"
+
+config SOC_PIC32MZDA
+	bool "Microchip PIC32MZ[DA] family"
+	select SUPPORTS_LITTLE_ENDIAN
+	select SUPPORTS_CPU_MIPS32_R1
+	select SUPPORTS_CPU_MIPS32_R2
+	select MIPS_L1_CACHE_SHIFT_4
+	select SYS_MIPS_CACHE_INIT_RAM_LOAD
+	help
+	  This supports Microchip PIC32MZ[DA] family of microcontrollers.
+
+endchoice
 
 endmenu
arch/mips/mach-pic32/Makefile +1 -1
index cb42607..e321e65 100644
@@ -4,4 +4,4 @@
 # SPDX-License-Identifier:      GPL-2.0+
 #
 
-obj-y = cpu.o
+obj-y = cpu.o lowlevel_init.o reset.o
\ No newline at end of file
arch/mips/mach-pic32/cpu.c +143 -0
index 58fd3ab..f2ee911 100644
@@ -6,8 +6,151 @@
  *
  */
 #include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <mach/pic32.h>
+#include <mach/ddr.h>
+#include <dt-bindings/clock/microchip,clock.h>
 
+/* Flash prefetch */
+#define PRECON          0x00
+
+/* Flash ECCCON */
+#define ECC_MASK	0x03
+#define ECC_SHIFT	4
+
+#define CLK_MHZ(x)	((x) / 1000000)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static ulong clk_get_cpu_rate(void)
+{
+	int ret;
+	struct udevice *dev;
+
+	ret = uclass_get_device(UCLASS_CLK, 0, &dev);
+	if (ret) {
+		panic("uclass-clk: device not found\n");
+		return 0;
+	}
+
+	return clk_get_rate(dev);
+}
+
+/* initialize prefetch module related to cpu_clk */
+static void prefetch_init(void)
+{
+	struct pic32_reg_atomic *regs;
+	const void __iomem *base;
+	int v, nr_waits;
+	ulong rate;
+
+	/* cpu frequency in MHZ */
+	rate = clk_get_cpu_rate() / 1000000;
+
+	/* get flash ECC type */
+	base = pic32_get_syscfg_base();
+	v = (readl(base + CFGCON) >> ECC_SHIFT) & ECC_MASK;
+
+	if (v < 2) {
+		if (rate < 66)
+			nr_waits = 0;
+		else if (rate < 133)
+			nr_waits = 1;
+		else
+			nr_waits = 2;
+	} else {
+		if (rate <= 83)
+			nr_waits = 0;
+		else if (rate <= 166)
+			nr_waits = 1;
+		else
+			nr_waits = 2;
+	}
+
+	regs = ioremap(PREFETCH_BASE + PRECON, sizeof(*regs));
+	writel(nr_waits, &regs->raw);
+
+	/* Enable prefetch for all */
+	writel(0x30, &regs->set);
+	iounmap(regs);
+}
+
+/* arch specific CPU init after DM */
+int arch_cpu_init_dm(void)
+{
+	/* flash prefetch */
+	prefetch_init();
+	return 0;
+}
+
+/* Un-gate DDR2 modules (gated by default) */
+static void ddr2_pmd_ungate(void)
+{
+	void __iomem *regs;
+
+	regs = pic32_get_syscfg_base();
+	writel(0, regs + PMD7);
+}
+
+/* initialize the DDR2 Controller and DDR2 PHY */
 phys_size_t initdram(int board_type)
 {
+	ddr2_pmd_ungate();
+	ddr2_phy_init();
+	ddr2_ctrl_init();
+	return ddr2_calculate_size();
+}
+
+int misc_init_r(void)
+{
+	set_io_port_base(0);
+	return 0;
+}
+
+#ifdef CONFIG_DISPLAY_BOARDINFO
+const char *get_core_name(void)
+{
+	u32 proc_id;
+	const char *str;
+
+	proc_id = read_c0_prid();
+	switch (proc_id) {
+	case 0x19e28:
+		str = "PIC32MZ[DA]";
+		break;
+	default:
+		str = "UNKNOWN";
+	}
+
+	return str;
+}
+#endif
+#ifdef CONFIG_CMD_CLK
+int soc_clk_dump(void)
+{
+	int i, ret;
+	struct udevice *dev;
+
+	ret = uclass_get_device(UCLASS_CLK, 0, &dev);
+	if (ret) {
+		printf("clk-uclass not found\n");
+		return ret;
+	}
+
+	printf("PLL Speed: %lu MHz\n",
+	       CLK_MHZ(clk_get_periph_rate(dev, PLLCLK)));
+	printf("CPU Speed: %lu MHz\n", CLK_MHZ(clk_get_rate(dev)));
+	printf("MPLL Speed: %lu MHz\n",
+	       CLK_MHZ(clk_get_periph_rate(dev, MPLL)));
+
+	for (i = PB1CLK; i <= PB7CLK; i++)
+		printf("PB%d Clock Speed: %lu MHz\n", i - PB1CLK + 1,
+		       CLK_MHZ(clk_get_periph_rate(dev, i)));
+
+	for (i = REF1CLK; i <= REF5CLK; i++)
+		printf("REFO%d Clock Speed: %lu MHz\n", i - REF1CLK + 1,
+		       CLK_MHZ(clk_get_periph_rate(dev, i)));
 	return 0;
 }
+#endif
arch/mips/mach-pic32/include/mach/pic32.h +3 -0
index 7e41810..16bfacf 100644
@@ -73,4 +73,7 @@ static inline void __iomem *pic32_get_syscfg_base(void)
 	return (void __iomem *)CKSEG1ADDR(PIC32_CFG_BASE);
 }
 
+/* Core */
+const char *get_core_name(void);
+
 #endif	/* __PIC32_REGS_H__ */
arch/mips/mach-pic32/lowlevel_init.S new file +27 -0
new file mode 100644
index 0000000..e37bebb
@@ -0,0 +1,27 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+*/
+
+#include <config.h>
+#include <asm/regdef.h>
+#include <asm/mipsregs.h>
+#include <asm/asm.h>
+
+LEAF(lowlevel_init)
+	/*
+	 * Establish Cause
+	 * (set IV bit)
+	 */
+	li	t1, 0x00800000
+	mtc0	t1, CP0_CAUSE
+
+	/* Establish Wired (and Random) */
+	mtc0	zero, CP0_WIRED
+	 nop
+
+	jr	ra
+	 nop
+	END(lowlevel_init)
arch/mips/mach-pic32/reset.c new file +36 -0
new file mode 100644
index 0000000..66c6833
@@ -0,0 +1,36 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <mach/pic32.h>
+
+/* SYSKEY */
+#define UNLOCK_KEY1	0xaa996655
+#define UNLOCK_KEY2	0x556699aa
+#define LOCK_KEY	0
+
+#define RSWRST          0x1250
+
+void _machine_restart(void)
+{
+	void __iomem *base;
+
+	base = pic32_get_syscfg_base();
+
+	/* unlock sequence */
+	writel(LOCK_KEY, base + SYSKEY);
+	writel(UNLOCK_KEY1, base + SYSKEY);
+	writel(UNLOCK_KEY2, base + SYSKEY);
+
+	/* soft reset */
+	writel(0x1, base + RSWRST);
+	(void) readl(base + RSWRST);
+
+	while (1)
+		;
+}
Signature · 1 line
- Daniel
#9 lore raw

PATCH v4 8/13 board: Add Microchip PIC32MZ[DA]-Starter-Kit board.

In reply to Purna Chandra Mandal

This adds support for Microchip PIC32MZ[DA] StarterKit board based on a PIC32MZ[DA] family of microcontroller.

---

Changes in v4:
- create defconfig by 'make savedefconfig'
- drop explicit SYS_BAUDRATE_TABLE in favor of default one

Changes in v3:
- drop SKIP_LOWLEVEL_INIT, GBL_DATA_OFFSET from config header
- move CMD_MEMTEST, CMD_MEMINFO to defconfig
- increase SYS_MALLOC_F_LEN to 0x600
- use auto-generated defconfig - no hand edit

Changes in v2:
- move CONFIG_SYS_TEXT_BASE (from board/*/config.mk) to include/configs/<board>.h

 arch/mips/dts/Makefile                |  2 +-
 arch/mips/dts/pic32mzda_sk.dts        | 38 ++++++++++++++
 arch/mips/mach-pic32/Kconfig          | 13 +++++
 board/microchip/pic32mzda/Kconfig     | 13 +++++
 board/microchip/pic32mzda/MAINTAINERS |  6 +++
 board/microchip/pic32mzda/Makefile    |  7 +++
 board/microchip/pic32mzda/README      | 22 +++++++++
 board/microchip/pic32mzda/pic32mzda.c | 31 ++++++++++++
 configs/pic32mzdask_defconfig         | 30 +++++++++++
 include/configs/pic32mzdask.h         | 93 +++++++++++++++++++++++++++++++++++
 10 files changed, 254 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/dts/pic32mzda_sk.dts
 create mode 100644 board/microchip/pic32mzda/Kconfig
 create mode 100644 board/microchip/pic32mzda/MAINTAINERS
 create mode 100644 board/microchip/pic32mzda/Makefile
 create mode 100644 board/microchip/pic32mzda/README
 create mode 100644 board/microchip/pic32mzda/pic32mzda.c
 create mode 100644 configs/pic32mzdask_defconfig
 create mode 100644 include/configs/pic32mzdask.h
arch/mips/dts/Makefile +1 -1
index 47b6eb5..b513918 100644
@@ -2,7 +2,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-dtb-y +=
+dtb-$(CONFIG_TARGET_PIC32MZDASK) += pic32mzda_sk.dtb
 
 targets += $(dtb-y)
 
arch/mips/dts/pic32mzda_sk.dts new file +38 -0
new file mode 100644
index 0000000..99e7f64
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2015 Purna Chandra Mandal, purna.mandal at microchip.com
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+#include "pic32mzda.dtsi"
+
+/ {
+	model = "Microchip PIC32MZDASK";
+	compatible = "microchip,pic32mzdask", "microchip,pic32mzda";
+
+	aliases {
+		console = &uart2;
+		serial0 = &uart2;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&clock {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
+
+&pinctrl {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
+
+&uart2 {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
arch/mips/mach-pic32/Kconfig +13 -0
index f636266..2e38bb7 100644
@@ -19,4 +19,17 @@ config SOC_PIC32MZDA
 
 endchoice
 
+choice
+	prompt "Board select"
+
+config TARGET_PIC32MZDASK
+	bool "Microchip PIC32MZ[DA] Starter Kit"
+	depends on SOC_PIC32MZDA
+	help
+	  This supports Microchip PIC32MZ[DA] Starter Kit.
+
+endchoice
+
+source "board/microchip/pic32mzda/Kconfig"
+
 endmenu
board/microchip/pic32mzda/Kconfig new file +13 -0
new file mode 100644
index 0000000..8acb393
@@ -0,0 +1,13 @@
+
+if TARGET_PIC32MZDASK
+
+config SYS_BOARD
+	default "pic32mzda"
+
+config SYS_VENDOR
+	default "microchip"
+
+config SYS_CONFIG_NAME
+	default "pic32mzdask"
+
+endif
board/microchip/pic32mzda/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..c934f1a
@@ -0,0 +1,6 @@
+PIC32MZDASK BOARD
+M:	Purna Chandra Mandal <[email protected]>
+S:	Maintained
+F:	board/microchip/pic32mzda/
+F:	include/configs/pic32mzdask.h
+F:	configs/pic32mzdask_defconfig
board/microchip/pic32mzda/Makefile new file +7 -0
new file mode 100644
index 0000000..3629530
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2015
+# Purna Chandra Mandal, purna.mandal at microchip.com.
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+obj-y := pic32mzda.o
board/microchip/pic32mzda/README new file +22 -0
new file mode 100644
index 0000000..91d16ab
@@ -0,0 +1,22 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ */
+
+PIC32MZ[DA] Starter Kit
+----------------------------------------
+PIC32MZ[DA] Starter Kit is based on PIC32MZ[DA] family of micro-controller.
+This family is powered by MIPS M14KEC 32bit general purpose core and has
+advanced microcontroller features and peripherals.
+
+This processor boots with proprietary stage1 bootloader running from internal
+boot-flash. Stage1 bootloader inturns locates and jumps to U-Boot programmed
+on internal program-flash. Finally U-Boot loads OS image (along with other
+required files for booting) from either uSD card, or ethernet, or from USB
+storage.
+
+To boot Linux following three files are mandatory - uEnv.txt (custom U-Boot
+environment file), uImage, *.dtb (platform device-tree-blob file).
+
+U-Boot jumps to Linux using UHI specification.
+
+Visit http://microchip.com for details.
board/microchip/pic32mzda/pic32mzda.c new file +31 -0
new file mode 100644
index 0000000..afe2ab8
@@ -0,0 +1,31 @@
+/*
+ * Microchip PIC32MZ[DA] Starter Kit board
+ *
+ * Copyright (C) 2015, Microchip Technology Inc.
+ * Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <clk.h>
+#include <mach/pic32.h>
+
+#ifdef CONFIG_DISPLAY_BOARDINFO
+int checkboard(void)
+{
+	ulong rate = 0;
+	struct udevice *dev;
+
+	printf("Core: %s\n", get_core_name());
+
+	if (!uclass_get_device(UCLASS_CLK, 0, &dev)) {
+		rate = clk_get_rate(dev);
+		printf("CPU Speed: %lu MHz\n", rate / 1000000);
+	}
+
+	return 0;
+}
+#endif
configs/pic32mzdask_defconfig new file +30 -0
new file mode 100644
index 0000000..1c968fc
@@ -0,0 +1,30 @@
+CONFIG_MIPS=y
+CONFIG_SYS_MALLOC_F_LEN=0x600
+CONFIG_DM_SERIAL=y
+CONFIG_DM_GPIO=y
+CONFIG_MACH_PIC32=y
+# CONFIG_MIPS_BOOT_ENV_LEGACY is not set
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEFAULT_DEVICE_TREE="pic32mzda_sk"
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="dask # "
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_SAVEENV is not set
+CONFIG_LOOPW=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MEMINFO=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_NET is not set
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_TIME=y
+CONFIG_OF_EMBED=y
+CONFIG_CLK=y
+CONFIG_PINCTRL=y
+# CONFIG_PINCTRL_FULL is not set
+CONFIG_SYS_VSNPRINTF=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_REGEX=y
+CONFIG_CMD_DHRYSTONE=y
include/configs/pic32mzdask.h new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#10 lore raw

PATCH v4 8/13 board: Add Microchip PIC32MZ[DA]-Starter-Kit board.

Am 28.01.2016 um 11:00 schrieb Purna Chandra Mandal:

Quoted 4 lines

This adds support for Microchip PIC32MZ[DA] StarterKit board based on a PIC32MZ[DA] family of microcontroller.

Quoted 361 lines

---

Changes in v4:
- create defconfig by 'make savedefconfig'
- drop explicit SYS_BAUDRATE_TABLE in favor of default one

Changes in v3:
- drop SKIP_LOWLEVEL_INIT, GBL_DATA_OFFSET from config header
- move CMD_MEMTEST, CMD_MEMINFO to defconfig
- increase SYS_MALLOC_F_LEN to 0x600
- use auto-generated defconfig - no hand edit

Changes in v2:
- move CONFIG_SYS_TEXT_BASE (from board/*/config.mk) to include/configs/<board>.h

 arch/mips/dts/Makefile                |  2 +-
 arch/mips/dts/pic32mzda_sk.dts        | 38 ++++++++++++++
 arch/mips/mach-pic32/Kconfig          | 13 +++++
 board/microchip/pic32mzda/Kconfig     | 13 +++++
 board/microchip/pic32mzda/MAINTAINERS |  6 +++
 board/microchip/pic32mzda/Makefile    |  7 +++
 board/microchip/pic32mzda/README      | 22 +++++++++
 board/microchip/pic32mzda/pic32mzda.c | 31 ++++++++++++
 configs/pic32mzdask_defconfig         | 30 +++++++++++
 include/configs/pic32mzdask.h         | 93 +++++++++++++++++++++++++++++++++++
 10 files changed, 254 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/dts/pic32mzda_sk.dts
 create mode 100644 board/microchip/pic32mzda/Kconfig
 create mode 100644 board/microchip/pic32mzda/MAINTAINERS
 create mode 100644 board/microchip/pic32mzda/Makefile
 create mode 100644 board/microchip/pic32mzda/README
 create mode 100644 board/microchip/pic32mzda/pic32mzda.c
 create mode 100644 configs/pic32mzdask_defconfig
 create mode 100644 include/configs/pic32mzdask.h
arch/mips/dts/Makefile +1 -1
index 47b6eb5..b513918 100644
@@ -2,7 +2,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-dtb-y +=
+dtb-$(CONFIG_TARGET_PIC32MZDASK) += pic32mzda_sk.dtb
 
 targets += $(dtb-y)
 
arch/mips/dts/pic32mzda_sk.dts new file +38 -0
new file mode 100644
index 0000000..99e7f64
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2015 Purna Chandra Mandal, purna.mandal at microchip.com
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+#include "pic32mzda.dtsi"
+
+/ {
+	model = "Microchip PIC32MZDASK";
+	compatible = "microchip,pic32mzdask", "microchip,pic32mzda";
+
+	aliases {
+		console = &uart2;
+		serial0 = &uart2;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&clock {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
+
+&pinctrl {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
+
+&uart2 {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
arch/mips/mach-pic32/Kconfig +13 -0
index f636266..2e38bb7 100644
@@ -19,4 +19,17 @@ config SOC_PIC32MZDA
 
 endchoice
 
+choice
+	prompt "Board select"
+
+config TARGET_PIC32MZDASK
+	bool "Microchip PIC32MZ[DA] Starter Kit"
+	depends on SOC_PIC32MZDA
+	help
+	  This supports Microchip PIC32MZ[DA] Starter Kit.
+
+endchoice
+
+source "board/microchip/pic32mzda/Kconfig"
+
 endmenu
board/microchip/pic32mzda/Kconfig new file +13 -0
new file mode 100644
index 0000000..8acb393
@@ -0,0 +1,13 @@
+
+if TARGET_PIC32MZDASK
+
+config SYS_BOARD
+	default "pic32mzda"
+
+config SYS_VENDOR
+	default "microchip"
+
+config SYS_CONFIG_NAME
+	default "pic32mzdask"
+
+endif
board/microchip/pic32mzda/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..c934f1a
@@ -0,0 +1,6 @@
+PIC32MZDASK BOARD
+M:	Purna Chandra Mandal <[email protected]>
+S:	Maintained
+F:	board/microchip/pic32mzda/
+F:	include/configs/pic32mzdask.h
+F:	configs/pic32mzdask_defconfig
board/microchip/pic32mzda/Makefile new file +7 -0
new file mode 100644
index 0000000..3629530
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2015
+# Purna Chandra Mandal, purna.mandal at microchip.com.
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+obj-y := pic32mzda.o
board/microchip/pic32mzda/README new file +22 -0
new file mode 100644
index 0000000..91d16ab
@@ -0,0 +1,22 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ */
+
+PIC32MZ[DA] Starter Kit
+----------------------------------------
+PIC32MZ[DA] Starter Kit is based on PIC32MZ[DA] family of micro-controller.
+This family is powered by MIPS M14KEC 32bit general purpose core and has
+advanced microcontroller features and peripherals.
+
+This processor boots with proprietary stage1 bootloader running from internal
+boot-flash. Stage1 bootloader inturns locates and jumps to U-Boot programmed
+on internal program-flash. Finally U-Boot loads OS image (along with other
+required files for booting) from either uSD card, or ethernet, or from USB
+storage.
+
+To boot Linux following three files are mandatory - uEnv.txt (custom U-Boot
+environment file), uImage, *.dtb (platform device-tree-blob file).
+
+U-Boot jumps to Linux using UHI specification.
+
+Visit http://microchip.com for details.
board/microchip/pic32mzda/pic32mzda.c new file +31 -0
new file mode 100644
index 0000000..afe2ab8
@@ -0,0 +1,31 @@
+/*
+ * Microchip PIC32MZ[DA] Starter Kit board
+ *
+ * Copyright (C) 2015, Microchip Technology Inc.
+ * Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <clk.h>
+#include <mach/pic32.h>
+
+#ifdef CONFIG_DISPLAY_BOARDINFO
+int checkboard(void)
+{
+	ulong rate = 0;
+	struct udevice *dev;
+
+	printf("Core: %s\n", get_core_name());
+
+	if (!uclass_get_device(UCLASS_CLK, 0, &dev)) {
+		rate = clk_get_rate(dev);
+		printf("CPU Speed: %lu MHz\n", rate / 1000000);
+	}
+
+	return 0;
+}
+#endif
configs/pic32mzdask_defconfig new file +30 -0
new file mode 100644
index 0000000..1c968fc
@@ -0,0 +1,30 @@
+CONFIG_MIPS=y
+CONFIG_SYS_MALLOC_F_LEN=0x600
+CONFIG_DM_SERIAL=y
+CONFIG_DM_GPIO=y
+CONFIG_MACH_PIC32=y
+# CONFIG_MIPS_BOOT_ENV_LEGACY is not set
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEFAULT_DEVICE_TREE="pic32mzda_sk"
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="dask # "
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_SAVEENV is not set
+CONFIG_LOOPW=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MEMINFO=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_NET is not set
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_TIME=y
+CONFIG_OF_EMBED=y
+CONFIG_CLK=y
+CONFIG_PINCTRL=y
+# CONFIG_PINCTRL_FULL is not set
+CONFIG_SYS_VSNPRINTF=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_REGEX=y
+CONFIG_CMD_DHRYSTONE=y
include/configs/pic32mzdask.h new file +93 -0
new file mode 100644
index 0000000..5ba2a19
@@ -0,0 +1,93 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * Microchip PIC32MZ[DA] Starter Kit.
+ */
+
+#ifndef __PIC32MZDASK_CONFIG_H
+#define __PIC32MZDASK_CONFIG_H
+
+/* System Configuration */
+#define CONFIG_SYS_TEXT_BASE		0x9d004000 /* .text */
+#define CONFIG_DISPLAY_BOARDINFO
+
+/*--------------------------------------------
+ * CPU configuration
+ */
+/* CPU Timer rate */
+#define CONFIG_SYS_MIPS_TIMER_FREQ	100000000
+
+/* Cache Configuration */
+#define CONFIG_SYS_MIPS_CACHE_MODE	CONF_CM_CACHABLE_NONCOHERENT
+
+/*----------------------------------------------------------------------
+ * Memory Layout
+ */
+#define CONFIG_SYS_SRAM_BASE		0x80000000
+#define CONFIG_SYS_SRAM_SIZE		0x00080000 /* 512K */
+
+/* Initial RAM for temporary stack, global data */
+#define CONFIG_SYS_INIT_RAM_SIZE	0x10000
+#define CONFIG_SYS_INIT_RAM_ADDR	\
+	(CONFIG_SYS_SRAM_BASE + CONFIG_SYS_SRAM_SIZE - CONFIG_SYS_INIT_RAM_SIZE)
+#define CONFIG_SYS_INIT_SP_ADDR		\
+	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE - 1)
+
+/* SDRAM Configuration (for final code, data, stack, heap) */
+#define CONFIG_SYS_SDRAM_BASE		0x88000000
+#define CONFIG_SYS_MALLOC_LEN		(256 << 10)
+#define CONFIG_SYS_BOOTPARAMS_LEN	(4 << 10)
+#define CONFIG_STACKSIZE		(4 << 10) /* regular stack */
+
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_MONITOR_LEN		(192 << 10)
+
+#define CONFIG_SYS_LOAD_ADDR		0x88500000 /* default load address */
+#define CONFIG_SYS_ENV_ADDR		0x88300000
+
+/* Memory Test */
+#define CONFIG_SYS_MEMTEST_START	0x88000000
+#define CONFIG_SYS_MEMTEST_END		0x88080000
+
+/*----------------------------------------------------------------------
+ * Commands
+ */
+#define CONFIG_SYS_LONGHELP		/* undef to save memory */
+#define CONFIG_CMD_CLK
+
+/*-------------------------------------------------
+ * FLASH configuration
+ */
+#define CONFIG_SYS_NO_FLASH
+
+/*------------------------------------------------------------
+ * Console Configuration
+ */
+#define CONFIG_BAUDRATE			115200
+#define CONFIG_SYS_CBSIZE		1024 /* Console I/O Buffer Size   */
+#define CONFIG_SYS_MAXARGS		16   /* max number of command args*/
+#define CONFIG_SYS_PBSIZE		\
+		(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_CMDLINE_EDITING		1
+
+/*
+ * Handover flattened device tree (dtb file) to Linux kernel
+ */
+#define CONFIG_OF_LIBFDT	1
+
+/* -------------------------------------------------
+ * Environment
+ */
+#define CONFIG_ENV_IS_NOWHERE	1
+#define CONFIG_ENV_SIZE		0x4000
+
+/* ---------------------------------------------------------------------
+ * Board boot configuration
+ */
+#define CONFIG_TIMESTAMP	/* Print image info with timestamp */
+#define CONFIG_BOOTDELAY	5 /* autoboot after X seconds     */
+#undef	CONFIG_BOOTARGS
+
+#endif	/* __PIC32MZDASK_CONFIG_H */
Signature · 1 line
- Daniel
#11 lore raw

PATCH v4 8/13 board: Add Microchip PIC32MZ[DA]-Starter-Kit board.

Quoted 7 lines · Daniel Schwierzeck

Am 28.01.2016 um 11:00 schrieb Purna Chandra Mandal:

Quoted 4 lines

This adds support for Microchip PIC32MZ[DA] StarterKit board based on a PIC32MZ[DA] family of microcontroller.

Thanks Daniel.
Could you please apply these patches in your tree?

Quoted 360 lines
Quoted 360 lines

---

Changes in v4:
- create defconfig by 'make savedefconfig'
- drop explicit SYS_BAUDRATE_TABLE in favor of default one

Changes in v3:
- drop SKIP_LOWLEVEL_INIT, GBL_DATA_OFFSET from config header
- move CMD_MEMTEST, CMD_MEMINFO to defconfig
- increase SYS_MALLOC_F_LEN to 0x600
- use auto-generated defconfig - no hand edit

Changes in v2:
- move CONFIG_SYS_TEXT_BASE (from board/*/config.mk) to include/configs/<board>.h

 arch/mips/dts/Makefile                |  2 +-
 arch/mips/dts/pic32mzda_sk.dts        | 38 ++++++++++++++
 arch/mips/mach-pic32/Kconfig          | 13 +++++
 board/microchip/pic32mzda/Kconfig     | 13 +++++
 board/microchip/pic32mzda/MAINTAINERS |  6 +++
 board/microchip/pic32mzda/Makefile    |  7 +++
 board/microchip/pic32mzda/README      | 22 +++++++++
 board/microchip/pic32mzda/pic32mzda.c | 31 ++++++++++++
 configs/pic32mzdask_defconfig         | 30 +++++++++++
 include/configs/pic32mzdask.h         | 93 +++++++++++++++++++++++++++++++++++
 10 files changed, 254 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/dts/pic32mzda_sk.dts
 create mode 100644 board/microchip/pic32mzda/Kconfig
 create mode 100644 board/microchip/pic32mzda/MAINTAINERS
 create mode 100644 board/microchip/pic32mzda/Makefile
 create mode 100644 board/microchip/pic32mzda/README
 create mode 100644 board/microchip/pic32mzda/pic32mzda.c
 create mode 100644 configs/pic32mzdask_defconfig
 create mode 100644 include/configs/pic32mzdask.h
arch/mips/dts/Makefile +1 -1
index 47b6eb5..b513918 100644
@@ -2,7 +2,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-dtb-y +=
+dtb-$(CONFIG_TARGET_PIC32MZDASK) += pic32mzda_sk.dtb
 
 targets += $(dtb-y)
 
arch/mips/dts/pic32mzda_sk.dts new file +38 -0
new file mode 100644
index 0000000..99e7f64
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2015 Purna Chandra Mandal, purna.mandal at microchip.com
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+#include "pic32mzda.dtsi"
+
+/ {
+	model = "Microchip PIC32MZDASK";
+	compatible = "microchip,pic32mzdask", "microchip,pic32mzda";
+
+	aliases {
+		console = &uart2;
+		serial0 = &uart2;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&clock {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
+
+&pinctrl {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
+
+&uart2 {
+	status = "okay";
+	u-boot,dm-pre-reloc;
+};
arch/mips/mach-pic32/Kconfig +13 -0
index f636266..2e38bb7 100644
@@ -19,4 +19,17 @@ config SOC_PIC32MZDA
 
 endchoice
 
+choice
+	prompt "Board select"
+
+config TARGET_PIC32MZDASK
+	bool "Microchip PIC32MZ[DA] Starter Kit"
+	depends on SOC_PIC32MZDA
+	help
+	  This supports Microchip PIC32MZ[DA] Starter Kit.
+
+endchoice
+
+source "board/microchip/pic32mzda/Kconfig"
+
 endmenu
board/microchip/pic32mzda/Kconfig new file +13 -0
new file mode 100644
index 0000000..8acb393
@@ -0,0 +1,13 @@
+
+if TARGET_PIC32MZDASK
+
+config SYS_BOARD
+	default "pic32mzda"
+
+config SYS_VENDOR
+	default "microchip"
+
+config SYS_CONFIG_NAME
+	default "pic32mzdask"
+
+endif
board/microchip/pic32mzda/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..c934f1a
@@ -0,0 +1,6 @@
+PIC32MZDASK BOARD
+M:	Purna Chandra Mandal <[email protected]>
+S:	Maintained
+F:	board/microchip/pic32mzda/
+F:	include/configs/pic32mzdask.h
+F:	configs/pic32mzdask_defconfig
board/microchip/pic32mzda/Makefile new file +7 -0
new file mode 100644
index 0000000..3629530
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2015
+# Purna Chandra Mandal, purna.mandal at microchip.com.
+#
+# SPDX-License-Identifier:      GPL-2.0+
+#
+obj-y := pic32mzda.o
board/microchip/pic32mzda/README new file +22 -0
new file mode 100644
index 0000000..91d16ab
@@ -0,0 +1,22 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ */
+
+PIC32MZ[DA] Starter Kit
+----------------------------------------
+PIC32MZ[DA] Starter Kit is based on PIC32MZ[DA] family of micro-controller.
+This family is powered by MIPS M14KEC 32bit general purpose core and has
+advanced microcontroller features and peripherals.
+
+This processor boots with proprietary stage1 bootloader running from internal
+boot-flash. Stage1 bootloader inturns locates and jumps to U-Boot programmed
+on internal program-flash. Finally U-Boot loads OS image (along with other
+required files for booting) from either uSD card, or ethernet, or from USB
+storage.
+
+To boot Linux following three files are mandatory - uEnv.txt (custom U-Boot
+environment file), uImage, *.dtb (platform device-tree-blob file).
+
+U-Boot jumps to Linux using UHI specification.
+
+Visit http://microchip.com for details.
board/microchip/pic32mzda/pic32mzda.c new file +31 -0
new file mode 100644
index 0000000..afe2ab8
@@ -0,0 +1,31 @@
+/*
+ * Microchip PIC32MZ[DA] Starter Kit board
+ *
+ * Copyright (C) 2015, Microchip Technology Inc.
+ * Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <clk.h>
+#include <mach/pic32.h>
+
+#ifdef CONFIG_DISPLAY_BOARDINFO
+int checkboard(void)
+{
+	ulong rate = 0;
+	struct udevice *dev;
+
+	printf("Core: %s\n", get_core_name());
+
+	if (!uclass_get_device(UCLASS_CLK, 0, &dev)) {
+		rate = clk_get_rate(dev);
+		printf("CPU Speed: %lu MHz\n", rate / 1000000);
+	}
+
+	return 0;
+}
+#endif
configs/pic32mzdask_defconfig new file +30 -0
new file mode 100644
index 0000000..1c968fc
@@ -0,0 +1,30 @@
+CONFIG_MIPS=y
+CONFIG_SYS_MALLOC_F_LEN=0x600
+CONFIG_DM_SERIAL=y
+CONFIG_DM_GPIO=y
+CONFIG_MACH_PIC32=y
+# CONFIG_MIPS_BOOT_ENV_LEGACY is not set
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_DEFAULT_DEVICE_TREE="pic32mzda_sk"
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="dask # "
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_SAVEENV is not set
+CONFIG_LOOPW=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MEMINFO=y
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+CONFIG_CMD_GPIO=y
+# CONFIG_CMD_NET is not set
+# CONFIG_CMD_NFS is not set
+CONFIG_CMD_TIME=y
+CONFIG_OF_EMBED=y
+CONFIG_CLK=y
+CONFIG_PINCTRL=y
+# CONFIG_PINCTRL_FULL is not set
+CONFIG_SYS_VSNPRINTF=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_REGEX=y
+CONFIG_CMD_DHRYSTONE=y
include/configs/pic32mzdask.h new file +93 -0
new file mode 100644
index 0000000..5ba2a19
@@ -0,0 +1,93 @@
+/*
+ * (c) 2015 Purna Chandra Mandal <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ *
+ * Microchip PIC32MZ[DA] Starter Kit.
+ */
+
+#ifndef __PIC32MZDASK_CONFIG_H
+#define __PIC32MZDASK_CONFIG_H
+
+/* System Configuration */
+#define CONFIG_SYS_TEXT_BASE		0x9d004000 /* .text */
+#define CONFIG_DISPLAY_BOARDINFO
+
+/*--------------------------------------------
+ * CPU configuration
+ */
+/* CPU Timer rate */
+#define CONFIG_SYS_MIPS_TIMER_FREQ	100000000
+
+/* Cache Configuration */
+#define CONFIG_SYS_MIPS_CACHE_MODE	CONF_CM_CACHABLE_NONCOHERENT
+
+/*----------------------------------------------------------------------
+ * Memory Layout
+ */
+#define CONFIG_SYS_SRAM_BASE		0x80000000
+#define CONFIG_SYS_SRAM_SIZE		0x00080000 /* 512K */
+
+/* Initial RAM for temporary stack, global data */
+#define CONFIG_SYS_INIT_RAM_SIZE	0x10000
+#define CONFIG_SYS_INIT_RAM_ADDR	\
+	(CONFIG_SYS_SRAM_BASE + CONFIG_SYS_SRAM_SIZE - CONFIG_SYS_INIT_RAM_SIZE)
+#define CONFIG_SYS_INIT_SP_ADDR		\
+	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE - 1)
+
+/* SDRAM Configuration (for final code, data, stack, heap) */
+#define CONFIG_SYS_SDRAM_BASE		0x88000000
+#define CONFIG_SYS_MALLOC_LEN		(256 << 10)
+#define CONFIG_SYS_BOOTPARAMS_LEN	(4 << 10)
+#define CONFIG_STACKSIZE		(4 << 10) /* regular stack */
+
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BASE
+#define CONFIG_SYS_MONITOR_LEN		(192 << 10)
+
+#define CONFIG_SYS_LOAD_ADDR		0x88500000 /* default load address */
+#define CONFIG_SYS_ENV_ADDR		0x88300000
+
+/* Memory Test */
+#define CONFIG_SYS_MEMTEST_START	0x88000000
+#define CONFIG_SYS_MEMTEST_END		0x88080000
+
+/*----------------------------------------------------------------------
+ * Commands
+ */
+#define CONFIG_SYS_LONGHELP		/* undef to save memory */
+#define CONFIG_CMD_CLK
+
+/*-------------------------------------------------
+ * FLASH configuration
+ */
+#define CONFIG_SYS_NO_FLASH
+
+/*------------------------------------------------------------
+ * Console Configuration
+ */
+#define CONFIG_BAUDRATE			115200
+#define CONFIG_SYS_CBSIZE		1024 /* Console I/O Buffer Size   */
+#define CONFIG_SYS_MAXARGS		16   /* max number of command args*/
+#define CONFIG_SYS_PBSIZE		\
+		(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_CMDLINE_EDITING		1
+
+/*
+ * Handover flattened device tree (dtb file) to Linux kernel
+ */
+#define CONFIG_OF_LIBFDT	1
+
+/* -------------------------------------------------
+ * Environment
+ */
+#define CONFIG_ENV_IS_NOWHERE	1
+#define CONFIG_ENV_SIZE		0x4000
+
+/* ---------------------------------------------------------------------
+ * Board boot configuration
+ */
+#define CONFIG_TIMESTAMP	/* Print image info with timestamp */
+#define CONFIG_BOOTDELAY	5 /* autoboot after X seconds     */
+#undef	CONFIG_BOOTARGS
+
+#endif	/* __PIC32MZDASK_CONFIG_H */
#12 lore raw

PATCH v4 9/13 drivers: mmc: add driver for Microchip PIC32 SDHCI controller.

In reply to Purna Chandra Mandal

From: Andrei Pistirica <[email protected]>

This driver implements platform specific glue and fixups for PIC32 internal SDHCI controller.

---

Changes in v4:
- update Kconfig help message
- add CD errata under SDHCI_QUIRK_NO_CD

Changes in v3:
- remove ofdata_to_platdata, and replace platdata with priv
- replace pic32_ioremap() with ioremap()

Changes in v2:
- drop sdhci shared bus configuration (for shared interrupt, clock pins)

 drivers/mmc/Kconfig       |  6 +++++
 drivers/mmc/Makefile      |  2 +-
 drivers/mmc/pic32_sdhci.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mmc/sdhci.c       |  7 ++++++
 4 files changed, 72 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mmc/pic32_sdhci.c
drivers/mmc/Kconfig +6 -0
index ceae7bc..9f4b766 100644
@@ -31,4 +31,10 @@ config SH_SDHI
 	help
 	  Support for the on-chip SDHI host controller on SuperH/Renesas ARM SoCs platform
 
+config PIC32_SDHCI
+	bool "Microchip PIC32 on-chip SDHCI support"
+	depends on DM_MMC && MACH_PIC32
+	help
+	  Support for Microchip PIC32 SDHCI controller.
+
 endmenu
drivers/mmc/Makefile +1 -1
index 5d35705..c9c3e3e 100644
@@ -48,4 +48,4 @@ obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o
 else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
-
+obj-$(CONFIG_PIC32_SDHCI) += pic32_sdhci.o
drivers/mmc/pic32_sdhci.c new file +58 -0

58 lines not on this page · raw message

drivers/mmc/sdhci.c +7 -0
index 02d71b9..f77b707 100644
@@ -443,6 +443,12 @@ static int sdhci_init(struct mmc *mmc)
 	sdhci_set_power(host, fls(mmc->cfg->voltages) - 1);
 
 	if (host->quirks & SDHCI_QUIRK_NO_CD) {
+#if defined(CONFIG_PIC32_SDHCI)
+		/* PIC32 SDHCI CD errata:
+		 * - set CD_TEST and clear CD_TEST_INS bit
+		 */
+		sdhci_writeb(host, SDHCI_CTRL_CD_TEST, SDHCI_HOST_CONTROL);
+#else
 		unsigned int status;
 
 		sdhci_writeb(host, SDHCI_CTRL_CD_TEST_INS | SDHCI_CTRL_CD_TEST,
@@ -453,6 +459,7 @@ static int sdhci_init(struct mmc *mmc)
 		    (!(status & SDHCI_CARD_STATE_STABLE)) ||
 		    (!(status & SDHCI_CARD_DETECT_PIN_LEVEL)))
 			status = sdhci_readl(host, SDHCI_PRESENT_STATE);
+#endif
 	}
 
 	/* Enable only interrupts served by the SD controller */
Signature · 1 line
1.8.3.1
#13 lore raw

PATCH v4 10/13 board: add SDHCI support for PIC32MZDASK board.

In reply to Purna Chandra Mandal

Enable MMC, SDHCI, FAT_FS support for PIC32MZ[DA] StarterKit. Also add custom scripts, rules to boot Linux from microSD card.

---

Changes in v4: None
Changes in v3:
- use distro boot commands from config_distro_bootcmd.h
- separate old booting logic as legacy_bootcmd

Changes in v2:
- drop shared bus (shared pin selection) configuration.

 arch/mips/dts/pic32mzda.dtsi   | 11 ++++++++
 arch/mips/dts/pic32mzda_sk.dts |  7 +++++
 configs/pic32mzdask_defconfig  |  3 ++-
 include/configs/pic32mzdask.h  | 59 ++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 77 insertions(+), 3 deletions(-)
arch/mips/dts/pic32mzda.dtsi +11 -0
index c67cfa9..f1894ec 100644
@@ -150,4 +150,15 @@
 			#gpio-cells = <2>;
 		};
 	};
+
+	sdhci: sdhci at 1f8ec000 {
+		compatible = "microchip,pic32mzda-sdhci";
+		reg = <0x1f8ec000 0x100>;
+		interrupts = <191 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock REF4CLK>, <&clock PB5CLK>;
+		clock-names = "base_clk", "sys_clk";
+		clock-freq-min-max = <25000000>,<25000000>;
+		bus-width = <4>;
+		status = "disabled";
+	};
 };
arch/mips/dts/pic32mzda_sk.dts +7 -0
index 99e7f64..f886a0f 100644
@@ -23,6 +23,9 @@
 };
 
 &clock {
+	microchip,refo2-frequency = <50000000>;
+	microchip,refo4-frequency = <25000000>;
+	microchip,refo5-frequency = <40000000>;
 	status = "okay";
 	u-boot,dm-pre-reloc;
 };
@@ -36,3 +39,7 @@
 	status = "okay";
 	u-boot,dm-pre-reloc;
 };
+
+&sdhci {
+	status = "okay";
+};
\ No newline at end of file
configs/pic32mzdask_defconfig +2 -1
index 1c968fc..55ba3f8 100644
@@ -9,7 +9,6 @@ CONFIG_DEFAULT_DEVICE_TREE="pic32mzda_sk"
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="dask # "
 # CONFIG_CMD_IMLS is not set
-# CONFIG_CMD_EXPORTENV is not set
 # CONFIG_CMD_SAVEENV is not set
 CONFIG_LOOPW=y
 CONFIG_CMD_MEMTEST=y
@@ -22,6 +21,8 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_TIME=y
 CONFIG_OF_EMBED=y
 CONFIG_CLK=y
+CONFIG_DM_MMC=y
+CONFIG_PIC32_SDHCI=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_FULL is not set
 CONFIG_SYS_VSNPRINTF=y
include/configs/pic32mzdask.h +57 -2

76 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#14 lore raw

PATCH v4 11/13 drivers: net: phy: add SMSC LAN8740 Phy support.

In reply to Purna Chandra Mandal

Add SMSC LAN8740 Phy support required for PIC32MZDA devices.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/net/phy/smsc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/phy/smsc.c +10 -0
index bfd9815..34986a2 100644
@@ -69,11 +69,21 @@ static struct phy_driver lan8710_driver = {
 	.shutdown = &genphy_shutdown,
 };
 
+static struct phy_driver lan8740_driver = {
+	.name = "SMSC LAN8740",
+	.uid = 0x0007c110,
+	.mask = 0xffff0,
+	.features = PHY_BASIC_FEATURES,
+	.config = &genphy_config_aneg,
+	.startup = &genphy_startup,
+	.shutdown = &genphy_shutdown,
+};
 int phy_smsc_init(void)
 {
 	phy_register(&lan8710_driver);
 	phy_register(&lan911x_driver);
 	phy_register(&lan8700_driver);
+	phy_register(&lan8740_driver);
 
 	return 0;
 }
Signature · 1 line
1.8.3.1
#16 lore raw

PATCH v4 12/13 drivers: net: Add ethernet driver for Microchip PIC32.

In reply to Purna Chandra Mandal

This driver implements MAC and MII layer of the ethernet controller. Network data transfer is handled by controller internal DMA engine. Ethernet controller is configurable through device-tree file.

---

Changes in v4:
- drop ioremap() success check
- drop _dcache_flush/invalidate() helpers for flash/invalidate_dcache_range().

Changes in v3:
- merge wrappers with eth operation callbacks
- read phy address from device-tree
- rename functions (e.g. _eth_xyz() with pic32_eth_xyz())

Changes in v2: None

 drivers/net/Kconfig      |   8 +
 drivers/net/Makefile     |   1 +
 drivers/net/pic32_eth.c  | 605 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/pic32_eth.h  | 164 +++++++++++++
 drivers/net/pic32_mdio.c | 121 ++++++++++
 5 files changed, 899 insertions(+)
 create mode 100644 drivers/net/pic32_eth.c
 create mode 100644 drivers/net/pic32_eth.h
 create mode 100644 drivers/net/pic32_mdio.c
drivers/net/Kconfig +8 -0
index de54ca8..1502f8e 100644
@@ -109,4 +109,12 @@ config ZYNQ_GEM
 	help
 	  This MAC is present in Xilinx Zynq and ZynqMP SoCs.
 
+config PIC32_ETH
+	bool "Microchip PIC32 Ethernet Support"
+	depends on DM_ETH && MACH_PIC32
+	select PHYLIB
+	help
+	  This driver implements 10/100 Mbps Ethernet and MAC layer for
+	  Microchip PIC32 microcontrollers.
+
 endif # NETDEVICES
drivers/net/Makefile +1 -0
index 150470c..33a81ee 100644
@@ -72,3 +72,4 @@ obj-$(CONFIG_FSL_MC_ENET) += fsl-mc/
 obj-$(CONFIG_FSL_MC_ENET) += ldpaa_eth/
 obj-$(CONFIG_FSL_MEMAC) += fm/memac_phy.o
 obj-$(CONFIG_VSC9953) += vsc9953.o
+obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o
drivers/net/pic32_eth.c new file +605 -0

605 lines not on this page · raw message

drivers/net/pic32_eth.h new file +164 -0

164 lines not on this page · raw message

drivers/net/pic32_mdio.c new file +121 -0

121 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#17 lore raw

PATCH v4 13/13 board: Enable ethernet, tftpboot support to pic32mzdask board.

In reply to Purna Chandra Mandal

This adds ethernet, TFTP support for PIC32MZ[DA] Starter Kit. Also custom environment variables/scripts are added to help boot from network.

---

Changes in v4: None
Changes in v3: None
Changes in v2:
- replace unbounded loop with wait_for_bit()
- replace register access as readl/writel(base + offset)
- translate (dts provided) physical address to MIPS kseg1 address before use

 arch/mips/dts/pic32mzda.dtsi   | 10 ++++++++++
 arch/mips/dts/pic32mzda_sk.dts | 10 ++++++++++
 configs/pic32mzdask_defconfig  |  9 ++++++---
 include/configs/pic32mzdask.h  | 22 +++++++++++++++++++++-
 4 files changed, 47 insertions(+), 4 deletions(-)
arch/mips/dts/pic32mzda.dtsi +10 -0
index f1894ec..7d180d9 100644
@@ -161,4 +161,14 @@
 		bus-width = <4>;
 		status = "disabled";
 	};
+
+	ethernet: ethernet at 1f882000 {
+		compatible = "microchip,pic32mzda-eth";
+		reg = <0x1f882000 0x1000>;
+		interrupts = <153 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock PB5CLK>;
+		status = "disabled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+	};
 };
arch/mips/dts/pic32mzda_sk.dts +10 -0
index f886a0f..e5ce0bd 100644
@@ -42,4 +42,14 @@
 
 &sdhci {
 	status = "okay";
+};
+
+&ethernet {
+	reset-gpios = <&gpioJ 15 0>;
+	status = "okay";
+	phy-mode = "rmii";
+	phy-handle = <&ethernet_phy>;
+	ethernet_phy: lan8740_phy at 0 {
+		reg = <0>;
+	};
 };
\ No newline at end of file
configs/pic32mzdask_defconfig +6 -3
index 55ba3f8..169a2ac 100644
@@ -16,16 +16,19 @@ CONFIG_CMD_MEMINFO=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_CMD_GPIO=y
-# CONFIG_CMD_NET is not set
-# CONFIG_CMD_NFS is not set
+CONFIG_CMD_RARP=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
 CONFIG_OF_EMBED=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_CLK=y
 CONFIG_DM_MMC=y
 CONFIG_PIC32_SDHCI=y
+CONFIG_DM_ETH=y
+CONFIG_PIC32_ETH=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_FULL is not set
 CONFIG_SYS_VSNPRINTF=y
 CONFIG_USE_TINY_PRINTF=y
-CONFIG_REGEX=y
 CONFIG_CMD_DHRYSTONE=y
include/configs/pic32mzdask.h +21 -1
index b258038..3ea1194 100644
@@ -73,6 +73,25 @@
 		(CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
 #define CONFIG_CMDLINE_EDITING		1
 
+/*-----------------------------------------------------------------------
+ * Networking Configuration
+ */
+#define CONFIG_MII
+#define CONFIG_PHY_SMSC
+#define CONFIG_SYS_RX_ETH_BUFFER	8
+#define CONFIG_NET_RETRY_COUNT		20
+#define CONFIG_ARP_TIMEOUT		500 /* millisec */
+
+#define CONFIG_CMD_MII
+
+/*
+ * BOOTP options
+ */
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
+
 /*
  * Handover flattened device tree (dtb file) to Linux kernel
  */
@@ -133,7 +152,8 @@
 		"fi; \0"
 
 #define BOOT_TARGET_DEVICES(func)	\
-	func(MMC, mmc, 0)
+	func(MMC, mmc, 0)		\
+	func(DHCP, dhcp, na)
 
 #include <config_distro_bootcmd.h>
 
Signature · 1 line
1.8.3.1
#18 lore raw

v4 cover Initial Microchip PIC32MZ[DA] Support

In reply to Purna Chandra Mandal

2016-01-28 11:00 GMT+01:00 Purna Chandra Mandal <[email protected]>:

Quoted 10 lines

This patch series adds support for Microchip PIC32MZ[DA] MIPS microcontroller platform. All drivers required to boot from MMC uSD card and network are included in it; clock, pinctrl, gpio, DDR2, serial, SDHCI, ethernet.
This series been tested on PIC32MZ[DA] Starter Kit.

This series is generated on u-boot/master branch. A tree with these changes is available at [1].

[1] https://github.com/purna-mandal/u-boot/tree/pic32-upstream-v4
[0] https://github.com/purna-mandal/u-boot/tree/pic32-upstream-v3

applied to u-boot-mips, thanks

Quoted 177 lines

Changes in v4:
- update kconfig dependency and default selection
- drop ioremap failure check
- gpio: return -EPERM if the pin is found in analog mode
- gpio: drop desc->offset setting in _gpio_xlate()
- serial: update comment for _pending_input().
- serial: rename UART_RX_OERR to UART_RX_OVER.
- serial: DEBUG_UART_PIC32 now depends on PIC32_SERIAL
- serial: extract clock-id from device-tree
- drop forcing DM_SERIAL, PIC32_SERIAL, PIC32_PINCTRL in mach-pic32/Kconfig
- drop extra includes
- rename clock compatible to "pic32mzda-clk" from "pic32mzda_clk".
- fix typo 'clock-cells' to '#clock-cells'
- create defconfig by 'make savedefconfig'
- drop explicit SYS_BAUDRATE_TABLE in favor of default one
- add CD errata under SDHCI_QUIRK_NO_CD
- eth: drop _dcache_flush/invalidate() helpers for flush/invalidate_dcache_range().

Changes in v3:
- drop empty choice in mach-pic32/Kconfig
- add pic32_get_syscfg_base()
- rename clk-pic32.c to clk_pic32.c
- update clock binding documentation
- replace pic32_ioremap() with ioremap()
- separate MPLL initialization constants
- read register base from device-tree
- add/update comments to explain how pinctrl'r works.
- replace pic32_ioremap() with ioremap().
- add check on dev_get_addr()
- remove ofdata_to_platdata, and replace platdata with priv
- remove special handling of '\r' as being handled by serial-uclass
- remove loop to wait for space in tx buffer before pumping char
- annotating fixed table with const
- fix camel-case in ddr2 timing parameters
- fix cmd index parameter of host_load_cmd().
- fix compilation warning
- drop forcing CONFIG_MIPS_BOOT_* selection in mach-pic32/Kconfig
- indent assembly instructions in delay slot
- made GPIO-nodes child of pinctrl-node in devicetree
- replace pic32_ioremap() with ioremap()
- drop SKIP_LOWLEVEL_INIT, GBL_DATA_OFFSET from config header
- move CMD_MEMTEST, CMD_MEMINFO to defconfig
- increase SYS_MALLOC_F_LEN to 0x600
- use auto-generated defconfig - no hand edit
- remove ofdata_to_platdata, and replace platdata with priv
- replace pic32_ioremap() with ioremap()
- use distro boot commands from config_distro_bootcmd.h
- separate old booting logic as legacy_bootcmd
- merge wrappers with eth operation callbacks
- read phy address from device-tree
- rename functions (e.g. _eth_xyz() with pic32_eth_xyz())

Changes in v2:
- move PIC32 specific headers to arch/mips/mach-pic32/include/mach/
- define register-base as physical address
- drop CONFIG_PIC32_SUPPORTS_FDT_BOOT
- add mpll get clock rate
- add pinconf routine for configuring pin property
- fix missing/corrupted chars during baud rate change
- remove loop until any char is avaialbale in getc()
- move ddr2 initialization from board/microchip/ to drivers/ddr/microchip
- drop board_early_init_f
- use macro LEAF(), END() for lowlevel_init
- move initialization of board_init_f() argument to common start.S
- move initdram() from board/microchip/ to mach-pic32/cpu.c
- remove MIPS virtual address in favor physical one in dts file
- move CONFIG_SYS_TEXT_BASE (from board/*/config.mk) to include/configs/<board>.h
- drop sdhci shared bus configuration (for shared interrupt, clock pins)
- drop shared bus (shared pin selection) configuration.
- replace unbounded loop with wait_for_bit()
- replace register access as readl/writel(base + offset)
- translate (dts provided) physical address to MIPS kseg1 address before use

Andrei Pistirica (1):
drivers: mmc: add driver for Microchip PIC32 SDHCI controller.

Paul Thacker (1):
drivers: serial: add driver for Microchip PIC32 UART controller.

Purna Chandra Mandal (11):
MIPS: initial infrastructure for Microchip PIC32 architecture
drivers: clk: Add clock driver for Microchip PIC32 Microcontroller.
drivers: pinctrl: Add pinctrl driver for Microchip PIC32.
drivers: gpio: add driver for Microchip PIC32 GPIO controller.
drivers: ddr: Add DDR2 SDRAM controller driver for Microchip PIC32.
MIPS: Add support for Microchip PIC32MZ[DA] SoC family.
board: Add Microchip PIC32MZ[DA]-Starter-Kit board.
board: add SDHCI support for PIC32MZDASK board.
drivers: net: phy: add SMSC LAN8740 Phy support.
drivers: net: Add ethernet driver for Microchip PIC32.
board: Enable ethernet, tftpboot support to pic32mzdask board.

 arch/mips/Kconfig                                  |   6 +
 arch/mips/Makefile                                 |   1 +
 arch/mips/dts/Makefile                             |   2 +-
 arch/mips/dts/pic32mzda.dtsi                       | 174 ++++++
 arch/mips/dts/pic32mzda_sk.dts                     |  55 ++
 arch/mips/mach-pic32/Kconfig                       |  35 ++
 arch/mips/mach-pic32/Makefile                      |   7 +
 arch/mips/mach-pic32/cpu.c                         | 156 ++++++
 arch/mips/mach-pic32/include/mach/ddr.h            |  32 ++
 arch/mips/mach-pic32/include/mach/pic32.h          |  79 +++
 arch/mips/mach-pic32/lowlevel_init.S               |  27 +
 arch/mips/mach-pic32/reset.c                       |  36 ++
 board/microchip/pic32mzda/Kconfig                  |  13 +
 board/microchip/pic32mzda/MAINTAINERS              |   6 +
 board/microchip/pic32mzda/Makefile                 |   7 +
 board/microchip/pic32mzda/README                   |  22 +
 board/microchip/pic32mzda/pic32mzda.c              |  31 ++
 configs/pic32mzdask_defconfig                      |  34 ++
 .../clock/microchip,pic32-clock.txt                |  33 ++
 .../serial/microchip,pic32-uart.txt                |   5 +
 drivers/Makefile                                   |   1 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk_pic32.c                            | 433 +++++++++++++++
 drivers/ddr/microchip/Makefile                     |   6 +
 drivers/ddr/microchip/ddr2.c                       | 278 ++++++++++
 drivers/ddr/microchip/ddr2_regs.h                  | 148 +++++
 drivers/ddr/microchip/ddr2_timing.h                |  65 +++
 drivers/gpio/Kconfig                               |   7 +
 drivers/gpio/Makefile                              |   2 +-
 drivers/gpio/pic32_gpio.c                          | 174 ++++++
 drivers/mmc/Kconfig                                |   6 +
 drivers/mmc/Makefile                               |   2 +-
 drivers/mmc/pic32_sdhci.c                          |  58 ++
 drivers/mmc/sdhci.c                                |   7 +
 drivers/net/Kconfig                                |   8 +
 drivers/net/Makefile                               |   1 +
 drivers/net/phy/smsc.c                             |  10 +
 drivers/net/pic32_eth.c                            | 605 +++++++++++++++++++++
 drivers/net/pic32_eth.h                            | 164 ++++++
 drivers/net/pic32_mdio.c                           | 121 +++++
 drivers/pinctrl/Kconfig                            |  10 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl_pic32.c                    | 363 +++++++++++++
 drivers/serial/Kconfig                             |  15 +
 drivers/serial/Makefile                            |   1 +
 drivers/serial/serial_pic32.c                      | 198 +++++++
 include/configs/pic32mzdask.h                      | 168 ++++++
 include/dt-bindings/clock/microchip,clock.h        |  29 +
 48 files changed, 3640 insertions(+), 3 deletions(-)
 create mode 100644 arch/mips/dts/pic32mzda.dtsi
 create mode 100644 arch/mips/dts/pic32mzda_sk.dts
 create mode 100644 arch/mips/mach-pic32/Kconfig
 create mode 100644 arch/mips/mach-pic32/Makefile
 create mode 100644 arch/mips/mach-pic32/cpu.c
 create mode 100644 arch/mips/mach-pic32/include/mach/ddr.h
 create mode 100644 arch/mips/mach-pic32/include/mach/pic32.h
 create mode 100644 arch/mips/mach-pic32/lowlevel_init.S
 create mode 100644 arch/mips/mach-pic32/reset.c
 create mode 100644 board/microchip/pic32mzda/Kconfig
 create mode 100644 board/microchip/pic32mzda/MAINTAINERS
 create mode 100644 board/microchip/pic32mzda/Makefile
 create mode 100644 board/microchip/pic32mzda/README
 create mode 100644 board/microchip/pic32mzda/pic32mzda.c
 create mode 100644 configs/pic32mzdask_defconfig
 create mode 100644 doc/device-tree-bindings/clock/microchip,pic32-clock.txt
 create mode 100644 doc/device-tree-bindings/serial/microchip,pic32-uart.txt
 create mode 100644 drivers/clk/clk_pic32.c
 create mode 100644 drivers/ddr/microchip/Makefile
 create mode 100644 drivers/ddr/microchip/ddr2.c
 create mode 100644 drivers/ddr/microchip/ddr2_regs.h
 create mode 100644 drivers/ddr/microchip/ddr2_timing.h
 create mode 100644 drivers/gpio/pic32_gpio.c
 create mode 100644 drivers/mmc/pic32_sdhci.c
 create mode 100644 drivers/net/pic32_eth.c
 create mode 100644 drivers/net/pic32_eth.h
 create mode 100644 drivers/net/pic32_mdio.c
 create mode 100644 drivers/pinctrl/pinctrl_pic32.c
 create mode 100644 drivers/serial/serial_pic32.c
 create mode 100644 include/configs/pic32mzdask.h
 create mode 100644 include/dt-bindings/clock/microchip,clock.h

--
1.8.3.1

Signature · 1 line
- Daniel