From 464918cf7157d6e84333a61da107de0233b59a9e Mon Sep 17 00:00:00 2001
From: Justin Schneck <jschneck@mac.com>
Date: Tue, 2 Jun 2020 00:14:05 -0400
Subject: [PATCH] giantboard support

---
 .../arm/boot/dts/at91-sama5d27_giantboard.dts | 353 ++++++++++++++++++
 .../boot/dts/at91-sama5d27_giantboard.dtsi    |  67 ++++
 2 files changed, 420 insertions(+)
 create mode 100644 arch/arm/boot/dts/at91-sama5d27_giantboard.dts
 create mode 100644 arch/arm/boot/dts/at91-sama5d27_giantboard.dtsi

diff --git a/arch/arm/boot/dts/at91-sama5d27_giantboard.dts b/arch/arm/boot/dts/at91-sama5d27_giantboard.dts
new file mode 100644
index 000000000..132d5fee3
--- /dev/null
+++ b/arch/arm/boot/dts/at91-sama5d27_giantboard.dts
@@ -0,0 +1,353 @@
+/*
+ * at91-sama5d27_giantboard.dts - Device Tree file for SAMA5D27 Giant Board
+ *
+ *  Copyright (c) 2017, Microchip Technology Inc.
+ *                2016 Nicolas Ferre <nicolas.ferre@atmel.com>
+ *                2017 Cristian Birsan <cristian.birsan@microchip.com>
+ *                2017 Claudiu Beznea <claudiu.beznea@microchip.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+/dts-v1/;
+#include "at91-sama5d27_giantboard.dtsi"
+#include <dt-bindings/mfd/atmel-flexcom.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/regulator/active-semi,8945a-regulator.h>
+
+/ {
+    model = "Giant Board";
+    compatible = "atmel,sama5d27-som1-ek", "atmel,sama5d27-som1", "atmel,sama5d27", "atmel,sama5d2", "atmel,sama5";
+
+    chosen {
+        stdout-path = "serial0:115200n8";
+    };
+
+    ahb {
+
+        usb0: gadget@300000 {
+            status = "okay";
+        };
+
+        usb1: ohci@400000 {
+            num-ports = <3>;
+            status = "okay";
+        };
+
+        usb2: ehci@500000 {
+            status = "okay";
+        };
+
+        sdmmc1: sdio-host@b0000000 {
+            bus-width = <4>;
+            pinctrl-names = "default";
+            pinctrl-0 = <&pinctrl_sdmmc1_default>;
+            status = "okay";
+        };
+
+        apb {
+
+            spi0: spi@f8000000 {
+                pinctrl-names = "default";
+                pinctrl-0 = <&pinctrl_spi0_default>;
+                status = "disabled";
+            };
+
+            uart1: serial@f8020000 {
+                pinctrl-names = "default";
+                pinctrl-0 = <&pinctrl_uart1_default>;
+                atmel,use-dma-rx;
+                atmel,use-dma-tx;
+                status = "okay";
+            };
+
+            flx4: flexcom@fc018000 {
+				status = "disabled";
+            };
+
+            shdwc@f8048010 {
+                atmel,shdwc-debouncer = <976>;
+                atmel,wakeup-rtc-timer;
+
+                input@0 {
+                    reg = <0>;
+                    atmel,wakeup-type = "low";
+                };
+            };
+
+            watchdog@f8048040 {
+                status = "okay";
+            };
+
+            i2s0: i2s@f8050000 {
+                status = "disabled";
+            };
+
+            i2c0: i2c@f8028000 {
+                dmas = <0>, <0>;
+                pinctrl-names = "default";
+                pinctrl-0 = <&pinctrl_i2c0_default>;
+                status = "disabled";
+            };
+
+            i2c1: i2c@fc028000 {
+                dmas = <0>, <0>;
+                pinctrl-names = "default";
+                pinctrl-0 = <&pinctrl_i2c1_default>;
+                i2c-sda-hold-time-ns = <350>;
+                status = "okay";
+
+                pmic@5b {
+                    compatible = "active-semi,act8945a";
+                    reg = <0x5b>;
+                    active-semi,vsel-low;
+                    status = "okay";
+
+                    regulators {
+
+                        vdd_1v8_reg: REG_DCDC1 {
+                            regulator-name = "VDD_1V8";
+                            regulator-min-microvolt = <1800000>;
+                            regulator-max-microvolt = <1800000>;
+                            regulator-always-on;
+
+                            regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+                                                      <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+                            regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+
+                            regulator-state-mem {
+                                regulator-on-in-suspend;
+                                regulator-suspend-min-microvolt=<1850000>;
+                                regulator-suspend-max-microvolt=<1850000>;
+                                regulator-changeable-in-suspend;
+                                regulator-mode=<ACT8945A_REGULATOR_MODE_LOWPOWER>;
+                            };
+                        };
+
+						vdd_1v2_reg: REG_DCDC2 {
+							regulator-name = "VDD_1V2";
+							regulator-min-microvolt = <1100000>;
+							regulator-max-microvolt = <1300000>;
+                            regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+                                                      <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+							regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+							regulator-always-on;
+
+							regulator-state-mem {
+								regulator-off-in-suspend;
+							};
+						};
+
+						vdd_3v3_reg: REG_DCDC3 {
+							regulator-name = "VDD_3V3";
+							regulator-min-microvolt = <3300000>;
+							regulator-max-microvolt = <3300000>;
+                            regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_FIXED>,
+										              <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+							regulator-initial-mode = <ACT8945A_REGULATOR_MODE_FIXED>;
+							regulator-always-on;
+
+							regulator-state-mem {
+								regulator-off-in-suspend;
+							};
+						};
+
+						vdd_fuse_reg: REG_LDO1 {
+							regulator-name = "VDD_FUSE";
+							regulator-min-microvolt = <2500000>;
+							regulator-max-microvolt = <2500000>;
+							regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+                                                      <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+							regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+ 							regulator-always-on;
+
+							regulator-state-mem {
+								regulator-off-in-suspend;
+							};
+						};
+
+						vdd_3v3_lp_reg: REG_LDO2 {
+							regulator-name = "VDD_3V3_LP";
+							regulator-min-microvolt = <3300000>;
+							regulator-max-microvolt = <3300000>;
+							regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+                                                      <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+							regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+							regulator-always-on;
+
+							regulator-state-mem {
+								regulator-off-in-suspend;
+							};
+						};
+
+						vdd_led_reg: REG_LDO3 {
+							regulator-name = "VDD_LED";
+							regulator-min-microvolt = <3300000>;
+							regulator-max-microvolt = <3300000>;
+							regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+                                                      <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+							regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+							regulator-always-on;
+
+							regulator-state-mem {
+								regulator-off-in-suspend;
+							};
+						};
+
+						vdd_sdhc_1v8_reg: REG_LDO4 {
+							regulator-name = "VDD_SDHC_1V8";
+							regulator-min-microvolt = <1800000>;
+							regulator-max-microvolt = <1800000>;
+							regulator-allowed-modes = <ACT8945A_REGULATOR_MODE_NORMAL>,
+                                                      <ACT8945A_REGULATOR_MODE_LOWPOWER>;
+							regulator-initial-mode = <ACT8945A_REGULATOR_MODE_NORMAL>;
+							regulator-always-on;
+
+							regulator-state-mem {
+								regulator-off-in-suspend;
+							};
+						};
+                    };
+
+                    charger {
+                        compatible = "active-semi,act8945a-charger";
+                        pinctrl-names = "default";
+                        pinctrl-0 = <&pinctrl_charger_chglev &pinctrl_charger_lbo &pinctrl_charger_irq>;
+                        interrupt-parent = <&pioA>;
+                        interrupts = <PIN_PB13 IRQ_TYPE_EDGE_RISING>;
+
+                        active-semi,chglev-gpios = <&pioA PIN_PA12 GPIO_ACTIVE_HIGH>;
+                        active-semi,lbo-gpios = <&pioA PIN_PC8 GPIO_ACTIVE_LOW>;
+                        active-semi,input-voltage-threshold-microvolt = <6600>;
+                        active-semi,precondition-timeout = <40>;
+                        active-semi,total-timeout = <3>;
+                        status = "okay";
+                    };
+                };
+            };
+
+            adc: adc@fc030000 {
+                vddana-supply = <&vdd_3v3_reg>;
+                vref-supply = <&vdd_3v3_reg>;
+                status = "disabled";
+            };
+
+            pwm0: pwm@f802c000 {
+                status = "disabled";
+            };
+
+            pinctrl@fc038000 {
+
+                pinctrl_i2c0_default: i2c0_default {
+                    pinmux = <PIN_PB31__TWD0>,
+                             <PIN_PC0__TWCK0>;
+                    bias-disable;
+                };
+
+                pinctrl_i2c1_default: i2c1_default {
+                    pinmux = <PIN_PD4__TWD1>,
+                             <PIN_PD5__TWCK1>;
+                    bias-disable;
+                };
+
+                pinctrl_led_gpio_default: led_gpio_default {
+                    pinmux = <PIN_PA6__GPIO>;
+                    bias-pull-down;
+                };
+
+                pinctrl_sdmmc1_default: sdmmc1_default {
+                    cmd_data {
+                        pinmux = <PIN_PA28__SDMMC1_CMD>,
+                                 <PIN_PA18__SDMMC1_DAT0>,
+                                 <PIN_PA19__SDMMC1_DAT1>,
+                                 <PIN_PA20__SDMMC1_DAT2>,
+                                 <PIN_PA21__SDMMC1_DAT3>;
+                        bias-pull-up;
+                    };
+
+                        conf-ck_cd {
+                        pinmux = <PIN_PA22__SDMMC1_CK>,
+                        <PIN_PA30__SDMMC1_CD>;
+                        bias-disable;
+                    };
+                };
+
+                pinctrl_spi0_default: spi0_default {
+                    pinmux = <PIN_PA14__SPI0_SPCK>,
+                             <PIN_PA15__SPI0_MOSI>,
+                             <PIN_PA16__SPI0_MISO>;
+                    bias-disable;
+                };
+
+                pinctrl_uart1_default: uart1_default {
+                    pinmux = <PIN_PD2__URXD1>,
+                             <PIN_PD3__UTXD1>;
+                    bias-disable;
+                };
+
+                pinctrl_charger_chglev: charger_chglev {
+                    pinmux = <PIN_PA12__GPIO>;
+                    bias-disable;
+                };
+
+                pinctrl_charger_irq: charger_irq {
+                    pinmux = <PIN_PB13__GPIO>;
+                    bias-disable;
+                };
+
+                pinctrl_charger_lbo: charger_lbo {
+                    pinmux = <PIN_PC8__GPIO>;
+                    bias-pull-up;
+                };
+            };
+        };
+    };
+
+    leds {
+        compatible = "gpio-leds";
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_led_gpio_default>;
+        status = "okay";
+
+        orange {
+            label = "orange";
+            gpios = <&pioA PIN_PA6 GPIO_ACTIVE_HIGH>;
+            linux,default-trigger = "mmc0";
+        };
+    };
+};
diff --git a/arch/arm/boot/dts/at91-sama5d27_giantboard.dtsi b/arch/arm/boot/dts/at91-sama5d27_giantboard.dtsi
new file mode 100644
index 000000000..2532740cd
--- /dev/null
+++ b/arch/arm/boot/dts/at91-sama5d27_giantboard.dtsi
@@ -0,0 +1,67 @@
+/*
+ * at91-sama5d27_som1.dtsi - Device Tree file for SAMA5D27 SoM1 board
+ *
+ *  Copyright (c) 2017, Microchip Technology Inc.
+ *                2017 Cristian Birsan <cristian.birsan@microchip.com>
+ *                2017 Claudiu Beznea <claudiu.beznea@microchip.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This file is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+#include "sama5d2.dtsi"
+#include "sama5d2-pinfunc.h"
+
+/ {
+	model = "Giant Board";
+	compatible = "atmel,sama5d27-som1", "atmel,sama5d27", "atmel,sama5d2", "atmel,sama5";
+
+	clocks {
+		slow_xtal {
+			clock-frequency = <32768>;
+		};
+
+		main_xtal {
+			clock-frequency = <24000000>;
+		};
+	};
+
+	ahb {
+		apb {
+		};
+	};
+};
-- 
2.25.1

