* [PATCH v2 01/11] ARM: add ARM946E-S CPU type
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 02/11] ARM: add very initial support for Canon DIGIC chips Antony Pavlov
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
ARM946E-S is used in the DIGIC family SoCs.
ARM946E-S core supports ARMv5TE and has Cache & MPU.
Linux kernel uses ARMv4 MPU cache routines for ARM946E-S core.
E.g. see linux.git/boot/compressed/head.S:
.word 0x41009400 @ ARM94x
.word 0xff00ff00
W(b) __armv4_mpu_cache_on
W(b) __armv4_mpu_cache_off
W(b) __armv4_mpu_cache_flush
So select CPU_32v4T for ARM946E-S despite of ARMv5TE support.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/arm/cpu/Kconfig | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/arch/arm/cpu/Kconfig b/arch/arm/cpu/Kconfig
index aed4cb7..fb1a999 100644
--- a/arch/arm/cpu/Kconfig
+++ b/arch/arm/cpu/Kconfig
@@ -39,6 +39,19 @@ config CPU_ARM926T
Say Y if you want support for the ARM926T processor.
Otherwise, say N.
+# ARM946E-S
+config CPU_ARM946E
+ bool
+ depends on !MMU
+ select CPU_32v4T
+ help
+ ARM946E-S is a member of the ARM9E-S family of high-
+ performance, 32-bit system-on-chip processor solutions.
+ The TCM and ARMv5TE 32-bit instruction set is supported.
+
+ Say Y if you want support for the ARM946E-S processor.
+ Otherwise, say N.
+
# Feroceon
config CPU_FEROCEON
bool
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 02/11] ARM: add very initial support for Canon DIGIC chips
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 01/11] ARM: add ARM946E-S CPU type Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 03/11] clocksource: add driver for Canon DIGIC timer Antony Pavlov
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/arm/Kconfig | 10 +++++++
arch/arm/Makefile | 1 +
arch/arm/dts/digic4.dtsi | 42 +++++++++++++++++++++++++++++
arch/arm/mach-digic/Kconfig | 8 ++++++
arch/arm/mach-digic/Makefile | 1 +
arch/arm/mach-digic/core.c | 25 +++++++++++++++++
arch/arm/mach-digic/include/mach/debug_ll.h | 40 +++++++++++++++++++++++++++
arch/arm/mach-digic/include/mach/digic4.h | 23 ++++++++++++++++
arch/arm/mach-digic/include/mach/uart.h | 28 +++++++++++++++++++
9 files changed, 178 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3af0197..ea0abcd 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -62,6 +62,15 @@ config ARCH_DAVINCI
select HAS_DEBUG_LL
select GPIOLIB
+config ARCH_DIGIC
+ bool "Canon DIGIC-based cameras"
+ select CPU_ARM946E
+ select HAS_DEBUG_LL
+ select CLOCKSOURCE_DIGIC
+ select GPIOLIB
+ help
+ Support for Canon's digital cameras that use the DIGIC4 chip.
+
config ARCH_EP93XX
bool "Cirrus Logic EP93xx"
select CPU_ARM920T
@@ -220,6 +229,7 @@ source arch/arm/mach-at91/Kconfig
source arch/arm/mach-bcm2835/Kconfig
source arch/arm/mach-clps711x/Kconfig
source arch/arm/mach-davinci/Kconfig
+source arch/arm/mach-digic/Kconfig
source arch/arm/mach-ep93xx/Kconfig
source arch/arm/mach-highbank/Kconfig
source arch/arm/mach-imx/Kconfig
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 983f7f5..1b0d7fe 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -55,6 +55,7 @@ machine-$(CONFIG_ARCH_AT91) := at91
machine-$(CONFIG_ARCH_BCM2835) := bcm2835
machine-$(CONFIG_ARCH_CLPS711X) := clps711x
machine-$(CONFIG_ARCH_DAVINCI) := davinci
+machine-$(CONFIG_ARCH_DIGIC) := digic
machine-$(CONFIG_ARCH_EP93XX) := ep93xx
machine-$(CONFIG_ARCH_HIGHBANK) := highbank
machine-$(CONFIG_ARCH_IMX) := imx
diff --git a/arch/arm/dts/digic4.dtsi b/arch/arm/dts/digic4.dtsi
new file mode 100644
index 0000000..21b004d
--- /dev/null
+++ b/arch/arm/dts/digic4.dtsi
@@ -0,0 +1,42 @@
+/include/ "skeleton.dtsi"
+
+/ {
+ compatible = "canon,digic4";
+
+ timer0: timer@c0210000 {
+ compatible = "canon,digic-timer";
+ reg = <0xc0210000 0x1c>;
+ status = "disabled";
+ };
+
+ timer1: timer@c0210100 {
+ compatible = "canon,digic-timer";
+ reg = <0xc0210100 0x1c>;
+ status = "disabled";
+ };
+
+ timer2: timer@c0210200 {
+ compatible = "canon,digic-timer";
+ reg = <0xc0210200 0x1c>;
+ status = "disabled";
+ };
+
+ /*
+ * I don't know real max GPIO number but this page
+ * http://magiclantern.wikia.com/wiki/Register_Map#GPIO_Ports
+ * says about 93 pins on 5DMkIII.
+ * Assume that DIGIC4 has at least 96 pins.
+ * So resource size is 96 * 4 = 0x180.
+ */
+ gpio: gpio {
+ compatible = "canon,digic-gpio";
+ reg = <0xc0220000 0x180>;
+ #gpio-cells = <2>;
+ gpio-controller;
+ };
+
+ uart: uart {
+ compatible = "canon,digic-uart";
+ reg = <0xc0800000 0x1c>;
+ };
+};
diff --git a/arch/arm/mach-digic/Kconfig b/arch/arm/mach-digic/Kconfig
new file mode 100644
index 0000000..49ce44a
--- /dev/null
+++ b/arch/arm/mach-digic/Kconfig
@@ -0,0 +1,8 @@
+if ARCH_DIGIC
+
+choice
+ prompt "camera type"
+
+endchoice
+
+endif
diff --git a/arch/arm/mach-digic/Makefile b/arch/arm/mach-digic/Makefile
new file mode 100644
index 0000000..820eb10
--- /dev/null
+++ b/arch/arm/mach-digic/Makefile
@@ -0,0 +1 @@
+obj-y += core.o
diff --git a/arch/arm/mach-digic/core.c b/arch/arm/mach-digic/core.c
new file mode 100644
index 0000000..b1caec0
--- /dev/null
+++ b/arch/arm/mach-digic/core.c
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+
+void __noreturn reset_cpu(unsigned long ignored)
+{
+ pr_err("%s: unimplemented\n", __func__);
+ hang();
+}
+EXPORT_SYMBOL(reset_cpu);
diff --git a/arch/arm/mach-digic/include/mach/debug_ll.h b/arch/arm/mach-digic/include/mach/debug_ll.h
new file mode 100644
index 0000000..721fd44
--- /dev/null
+++ b/arch/arm/mach-digic/include/mach/debug_ll.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2013, 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __MACH_DEBUG_LL_H__
+#define __MACH_DEBUG_LL_H__
+
+#include <io.h>
+#include <mach/digic4.h>
+#include <mach/uart.h>
+
+#define DEBUG_LL_UART DIGIC4_UART
+
+/* Serial interface registers */
+#define DEBUG_LL_UART_TX (DEBUG_LL_UART + DIGIC_UART_TX)
+#define DEBUG_LL_UART_ST (DEBUG_LL_UART + DIGIC_UART_ST)
+
+static inline void PUTC_LL(char ch)
+{
+ while (!(readl(DEBUG_LL_UART_ST) & DIGIC_UART_ST_TX_RDY))
+ ; /* noop */
+
+ writel(0x06, DEBUG_LL_UART_ST);
+ writel(ch, DEBUG_LL_UART_TX);
+}
+
+#endif /* __MACH_DEBUG_LL_H__ */
diff --git a/arch/arm/mach-digic/include/mach/digic4.h b/arch/arm/mach-digic/include/mach/digic4.h
new file mode 100644
index 0000000..ffc7979
--- /dev/null
+++ b/arch/arm/mach-digic/include/mach/digic4.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __DIGIC4_H__
+#define __DIGIC4_H__
+
+#define DIGIC4_UART 0xc0800000
+
+#endif /* __DIGIC4_H__ */
diff --git a/arch/arm/mach-digic/include/mach/uart.h b/arch/arm/mach-digic/include/mach/uart.h
new file mode 100644
index 0000000..043f7cd
--- /dev/null
+++ b/arch/arm/mach-digic/include/mach/uart.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __DIGIC_UART_H__
+#define __DIGIC_UART_H__
+
+/* Serial interface registers offsets */
+#define DIGIC_UART_TX 0x0
+#define DIGIC_UART_RX 0x4
+#define DIGIC_UART_ST 0x14
+# define DIGIC_UART_ST_RX_RDY 1
+# define DIGIC_UART_ST_TX_RDY 2
+
+#endif /* __DIGIC_UART_H__ */
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 03/11] clocksource: add driver for Canon DIGIC timer
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 01/11] ARM: add ARM946E-S CPU type Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 02/11] ARM: add very initial support for Canon DIGIC chips Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 04/11] serial: add driver for Canon DIGIC UART Antony Pavlov
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/clocksource/Kconfig | 4 ++
drivers/clocksource/Makefile | 1 +
drivers/clocksource/digic.c | 93 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 98 insertions(+)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index c1480ce..fc5a389 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -14,6 +14,10 @@ config CLOCKSOURCE_CLPS711X
bool
depends on ARCH_CLPS711X
+config CLOCKSOURCE_DIGIC
+ bool
+ depends on ARCH_DIGIC
+
config CLOCKSOURCE_DUMMY
bool "Enable dummy software-only clocksource"
help
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 97c0288..b80df6b 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_AMBA_SP804) += amba-sp804.o
obj-$(CONFIG_ARM_SMP_TWD) += arm_smp_twd.o
obj-$(CONFIG_CLOCKSOURCE_BCM2835) += bcm2835.o
obj-$(CONFIG_CLOCKSOURCE_CLPS711X) += clps711x.o
+obj-$(CONFIG_CLOCKSOURCE_DIGIC) += digic.o
obj-$(CONFIG_CLOCKSOURCE_DUMMY) += dummy.o
obj-$(CONFIG_CLOCKSOURCE_MVEBU) += mvebu.o
obj-$(CONFIG_CLOCKSOURCE_NOMADIK) += nomadik.o
diff --git a/drivers/clocksource/digic.c b/drivers/clocksource/digic.c
new file mode 100644
index 0000000..b80ef6f
--- /dev/null
+++ b/drivers/clocksource/digic.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2013, 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <io.h>
+#include <init.h>
+#include <clock.h>
+
+#define DIGIC_TIMER_CLOCK 1000000
+
+#define DIGIC_TIMER_CONTROL 0x00
+#define DIGIC_TIMER_VALUE 0x0c
+
+static void __iomem *timer_base;
+
+static uint64_t digic_cs_read(void)
+{
+ return (uint64_t)(0xffff - readl(timer_base + DIGIC_TIMER_VALUE));
+}
+
+static struct clocksource digic_cs = {
+ .read = digic_cs_read,
+ .mask = CLOCKSOURCE_MASK(16),
+};
+
+static int digic_timer_probe(struct device_d *dev)
+{
+ /* use only one timer */
+ if (timer_base)
+ return -EBUSY;
+
+ timer_base = dev_request_mem_region(dev, 0);
+ if (!timer_base) {
+ dev_err(dev, "could not get memory region\n");
+ return -ENODEV;
+ }
+
+ clocks_calc_mult_shift(&digic_cs.mult, &digic_cs.shift,
+ DIGIC_TIMER_CLOCK, NSEC_PER_SEC, 1);
+
+ /* disable timer */
+ writel(0x80000000, timer_base + DIGIC_TIMER_CONTROL);
+
+ /* magic values... divider? */
+ writel(0x00000002, timer_base + 0x04);
+ writel(0x00000003, timer_base + 0x14);
+
+ /* max counter value */
+ writel(0x0000ffff, timer_base + 0x08);
+
+ init_clock(&digic_cs);
+
+ /* enable timer */
+ writel(0x00000001, timer_base + DIGIC_TIMER_CONTROL);
+ /* start timer */
+ writel(0x00000001, timer_base + 0x10);
+
+ return 0;
+}
+
+static __maybe_unused struct of_device_id digic_timer_dt_ids[] = {
+ {
+ .compatible = "canon,digic-timer",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d digic_timer_driver = {
+ .probe = digic_timer_probe,
+ .name = "digic-timer",
+ .of_compatible = DRV_OF_COMPAT(digic_timer_dt_ids),
+};
+
+static int digic_timer_init(void)
+{
+ return platform_driver_register(&digic_timer_driver);
+}
+coredevice_initcall(digic_timer_init);
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 04/11] serial: add driver for Canon DIGIC UART
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (2 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 03/11] clocksource: add driver for Canon DIGIC timer Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 05/11] gpio: add driver for Canon DIGIC Antony Pavlov
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/serial/Kconfig | 4 ++
drivers/serial/Makefile | 1 +
drivers/serial/serial_digic.c | 132 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 137 insertions(+)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 5698c2f..146bf1e 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -133,4 +133,8 @@ config DRIVER_SERIAL_CADENCE
help
Say Y here if you have a Cadence serial IP core.
+config DRIVER_SERIAL_DIGIC
+ bool "Canon DIGIC serial driver"
+ depends on ARCH_DIGIC
+
endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 2c0176d..189e777 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -19,3 +19,4 @@ obj-$(CONFIG_DRIVER_SERIAL_OMAP4_USBBOOT) += serial_omap4_usbboot.o
obj-$(CONFIG_DRIVER_SERIAL_AUART) += serial_auart.o
obj-$(CONFIG_DRIVER_SERIAL_CADENCE) += serial_cadence.o
obj-$(CONFIG_DRIVER_SERIAL_EFI_STDIO) += efi-stdio.o
+obj-$(CONFIG_DRIVER_SERIAL_DIGIC) += serial_digic.o
diff --git a/drivers/serial/serial_digic.c b/drivers/serial/serial_digic.c
new file mode 100644
index 0000000..235ea0f
--- /dev/null
+++ b/drivers/serial/serial_digic.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2013, 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <io.h>
+
+#include <mach/uart.h>
+
+/*
+ * This driver is based on the "Serial terminal" docs here:
+ * http://magiclantern.wikia.com/wiki/Register_Map#Misc_Registers
+ *
+ * See also disassembler output for Canon A1100IS firmware
+ * (version a1100_100c):
+ * * a outc-like function can be found at address 0xffff18f0;
+ * * a getc-like function can be found at address 0xffff192c.
+ */
+
+static inline uint32_t digic_serial_readl(struct console_device *cdev,
+ uint32_t offset)
+{
+ void __iomem *base = cdev->dev->priv;
+
+ return readl(base + offset);
+}
+
+static inline void digic_serial_writel(struct console_device *cdev,
+ uint32_t value, uint32_t offset)
+{
+ void __iomem *base = cdev->dev->priv;
+
+ writel(value, base + offset);
+}
+
+static int digic_serial_setbaudrate(struct console_device *cdev, int baudrate)
+{
+ /* I don't know how to setup baudrate :( */
+
+ return 0;
+}
+
+static void digic_serial_putc(struct console_device *cdev, char c)
+{
+ uint32_t status;
+
+ do {
+ status = digic_serial_readl(cdev, DIGIC_UART_ST);
+ } while (!(status & DIGIC_UART_ST_TX_RDY));
+
+ digic_serial_writel(cdev, 0x06, DIGIC_UART_ST);
+ digic_serial_writel(cdev, c, DIGIC_UART_TX);
+}
+
+static int digic_serial_getc(struct console_device *cdev)
+{
+ uint32_t status;
+
+ do {
+ status = digic_serial_readl(cdev, DIGIC_UART_ST);
+ } while (!(status & DIGIC_UART_ST_RX_RDY));
+
+ digic_serial_writel(cdev, 0x01, DIGIC_UART_ST);
+
+ return digic_serial_readl(cdev, DIGIC_UART_RX);
+}
+
+static int digic_serial_tstc(struct console_device *cdev)
+{
+ uint32_t status = digic_serial_readl(cdev, DIGIC_UART_ST);
+
+ return ((status & DIGIC_UART_ST_RX_RDY) != 0);
+
+ /*
+ * Canon folks use additional check, something like this:
+ *
+ * if (digic_serial_readl(cdev, DIGIC_UART_ST) & 0x38) {
+ * digic_serial_writel(cdev, 0x38, DIGIC_UART_ST);
+ * return 0;
+ * }
+ *
+ * But I know nothing about these magic bits in the status register...
+ *
+ */
+}
+
+static int digic_serial_probe(struct device_d *dev)
+{
+ struct console_device *cdev;
+
+ cdev = xzalloc(sizeof(struct console_device));
+ dev->priv = dev_request_mem_region(dev, 0);
+ cdev->dev = dev;
+ cdev->tstc = &digic_serial_tstc;
+ cdev->putc = &digic_serial_putc;
+ cdev->getc = &digic_serial_getc;
+ cdev->setbrg = &digic_serial_setbaudrate;
+
+ console_register(cdev);
+
+ return 0;
+}
+
+static __maybe_unused struct of_device_id digic_serial_dt_ids[] = {
+ {
+ .compatible = "canon,digic-uart",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d digic_serial_driver = {
+ .name = "digic-uart",
+ .probe = digic_serial_probe,
+ .of_compatible = DRV_OF_COMPAT(digic_serial_dt_ids),
+};
+console_platform_driver(digic_serial_driver);
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 05/11] gpio: add driver for Canon DIGIC
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (3 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 04/11] serial: add driver for Canon DIGIC UART Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 06/11] ARM: DIGIC: add Canon PowerShot A1100 IS support Antony Pavlov
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/gpio/Kconfig | 4 ++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-digic.c | 180 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 185 insertions(+)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 6928fcb..0ca7df4 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -9,6 +9,10 @@ menu "GPIO"
config GPIO_GENERIC
bool
+config GPIO_DIGIC
+ bool "GPIO support for Canon DIGIC"
+ depends on ARCH_DIGIC
+
config GPIO_BCM2835
bool "GPIO support for BCM2835"
depends on ARCH_BCM2835
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index ece5efd..510d146 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_GPIOLIB) += gpiolib.o
obj-$(CONFIG_GPIO_BCM2835) += gpio-bcm2835.o
obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o
obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o
+obj-$(CONFIG_GPIO_DIGIC) += gpio-digic.o
obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
obj-$(CONFIG_GPIO_IMX) += gpio-imx.o
obj-$(CONFIG_GPIO_JZ4740) += gpio-jz4740.o
diff --git a/drivers/gpio/gpio-digic.c b/drivers/gpio/gpio-digic.c
new file mode 100644
index 0000000..468aaa7
--- /dev/null
+++ b/drivers/gpio/gpio-digic.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * See file CREDITS for list of people who contributed to this project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <errno.h>
+#include <io.h>
+#include <gpio.h>
+#include <init.h>
+
+/*
+ * See http://magiclantern.wikia.com/wiki/Register_Map#GPIO_Ports
+ */
+
+#define DIGIC_GPIO_IN_LVL 1
+#define DIGIC_GPIO_OUT_LVL 2
+#define DIGIC_GPIO_DIR 4
+#define DIGIC_GPIO_TRISTATE 8
+
+struct digic_gpio_chip {
+ void __iomem *base;
+ struct gpio_chip gc;
+};
+
+#define to_digic_gpio_chip(c) container_of(c, struct digic_gpio_chip, gc)
+
+static inline uint32_t digic_gpio_readl(struct digic_gpio_chip *chip,
+ uint32_t offset)
+{
+ return readl(chip->base + 4 * offset);
+}
+
+static inline void digic_gpio_writel(struct digic_gpio_chip *chip,
+ uint32_t value, uint32_t offset)
+{
+ writel(value, chip->base + 4 * offset);
+}
+
+static int digic_gpio_get_value(struct gpio_chip *gc, unsigned offset)
+{
+ struct digic_gpio_chip *chip = to_digic_gpio_chip(gc);
+
+ if (offset >= gc->ngpio)
+ return -EINVAL;
+
+ return digic_gpio_readl(chip, offset) & DIGIC_GPIO_IN_LVL;
+}
+
+static void digic_gpio_set_value(struct gpio_chip *gc, unsigned offset,
+ int value)
+{
+ struct digic_gpio_chip *chip = to_digic_gpio_chip(gc);
+ uint32_t t;
+
+ if (offset >= gc->ngpio)
+ return;
+
+ t = digic_gpio_readl(chip, offset);
+ /* Port direction (1 = OUT, 0 = IN) */
+ if (value)
+ t |= DIGIC_GPIO_OUT_LVL;
+ else
+ t &= ~(DIGIC_GPIO_OUT_LVL);
+ digic_gpio_writel(chip, t, offset);
+}
+
+static int digic_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
+{
+ struct digic_gpio_chip *chip = to_digic_gpio_chip(gc);
+ uint32_t t;
+
+ if (offset >= gc->ngpio)
+ return -EINVAL;
+
+ t = digic_gpio_readl(chip, offset);
+ /* Port direction (1 = OUT, 0 = IN) */
+ t &= ~(DIGIC_GPIO_DIR);
+ digic_gpio_writel(chip, t, offset);
+
+ return 0;
+}
+
+static int digic_gpio_direction_output(struct gpio_chip *gc, unsigned offset,
+ int value)
+{
+ struct digic_gpio_chip *chip = to_digic_gpio_chip(gc);
+ uint32_t t;
+
+ if (offset >= gc->ngpio)
+ return -EINVAL;
+
+ t = digic_gpio_readl(chip, offset);
+ /* Port direction (1 = OUT, 0 = IN) */
+ t |= DIGIC_GPIO_DIR;
+ digic_gpio_writel(chip, t, offset);
+
+ digic_gpio_set_value(gc, offset, value);
+
+ return 0;
+}
+
+static struct gpio_ops digic_gpio_ops = {
+ .direction_input = digic_gpio_direction_input,
+ .direction_output = digic_gpio_direction_output,
+ .get = digic_gpio_get_value,
+ .set = digic_gpio_set_value,
+};
+
+static int digic_gpio_probe(struct device_d *dev)
+{
+ struct digic_gpio_chip *chip;
+ struct resource *res;
+ resource_size_t rsize;
+ int ret = -EINVAL;
+
+ chip = xzalloc(sizeof(*chip));
+
+ res = dev_get_resource(dev, IORESOURCE_MEM, 0);
+ if (!res)
+ goto err;
+
+ rsize = resource_size(res);
+ chip->gc.ngpio = rsize / sizeof(int32_t);
+
+ chip->base = dev_request_mem_region(dev, 0);
+ chip->gc.ops = &digic_gpio_ops;
+ chip->gc.base = 0;
+
+ chip->gc.dev = dev;
+
+ ret = gpiochip_add(&chip->gc);
+ if (ret) {
+ dev_err(dev, "couldn't add gpiochip, ret = %d\n", ret);
+ goto err;
+ }
+
+ dev_info(dev, "probed gpiochip%d with base %d\n",
+ dev->id, chip->gc.base);
+
+ return 0;
+
+err:
+ kfree(chip);
+
+ return ret;
+}
+
+static __maybe_unused struct of_device_id digic_gpio_dt_ids[] = {
+ {
+ .compatible = "canon,digic-gpio",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d digic_gpio_driver = {
+ .name = "digic-gpio",
+ .probe = digic_gpio_probe,
+ .of_compatible = DRV_OF_COMPAT(digic_gpio_dt_ids),
+};
+
+static int digic_gpio_init(void)
+{
+ return platform_driver_register(&digic_gpio_driver);
+}
+coredevice_initcall(digic_gpio_init);
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 06/11] ARM: DIGIC: add Canon PowerShot A1100 IS support
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (4 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 05/11] gpio: add driver for Canon DIGIC Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 07/11] ARM: add Canon A1100 ROM image generation Antony Pavlov
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/arm/boards/Makefile | 1 +
arch/arm/boards/canon-a1100/Makefile | 1 +
arch/arm/boards/canon-a1100/lowlevel.c | 23 ++++++++++++++++++++++
arch/arm/dts/canon-a1100.dts | 35 ++++++++++++++++++++++++++++++++++
arch/arm/mach-digic/Kconfig | 7 +++++++
5 files changed, 67 insertions(+)
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 2ed3730..c60da81 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_MACH_AT91SAM9N12EK) += at91sam9n12ek/
obj-$(CONFIG_MACH_AT91SAM9X5EK) += at91sam9x5ek/
obj-$(CONFIG_MACH_BEAGLE) += beagle/
obj-$(CONFIG_MACH_BEAGLEBONE) += beaglebone/
+obj-$(CONFIG_MACH_CANON_A1100) += canon-a1100/
obj-$(CONFIG_MACH_NITROGEN6X) += boundarydevices-nitrogen6x/
obj-$(CONFIG_MACH_CCMX51) += ccxmx51/
obj-$(CONFIG_MACH_CFA10036) += crystalfontz-cfa10036/
diff --git a/arch/arm/boards/canon-a1100/Makefile b/arch/arm/boards/canon-a1100/Makefile
new file mode 100644
index 0000000..b08c4a9
--- /dev/null
+++ b/arch/arm/boards/canon-a1100/Makefile
@@ -0,0 +1 @@
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/canon-a1100/lowlevel.c b/arch/arm/boards/canon-a1100/lowlevel.c
new file mode 100644
index 0000000..bbae825
--- /dev/null
+++ b/arch/arm/boards/canon-a1100/lowlevel.c
@@ -0,0 +1,23 @@
+#include <common.h>
+#include <sizes.h>
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+
+void __naked barebox_arm_reset_vector(void)
+{
+ arm_cpu_lowlevel_init();
+
+ /* FIXME: can we determine RAM size using CP15 register?
+ *
+ * see http://chdk.setepontos.com/index.php?topic=5980.90
+ *
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0363e/Bgbcdeca.html
+ * 4.2.19. c6, MPU memory region programming registers
+ *
+ * But the 'cpuinfo' command says that the Protection
+ * unit is disabled.
+ * The Control Register value (mrc p15, 0, %0, c0, c1, 4)
+ * is 0x00051078.
+ */
+ barebox_arm_entry(0x0, SZ_64M, 0);
+}
diff --git a/arch/arm/dts/canon-a1100.dts b/arch/arm/dts/canon-a1100.dts
new file mode 100644
index 0000000..a88eacf
--- /dev/null
+++ b/arch/arm/dts/canon-a1100.dts
@@ -0,0 +1,35 @@
+/dts-v1/;
+
+/include/ "digic4.dtsi"
+
+/ {
+ model = "Canon PowerShot A1100 IS";
+ compatible = "canon,a1100";
+
+ memory {
+ reg = <0x00000000 0x04000000>;
+ };
+
+ flash@f8000000 {
+ compatible = "cfi-flash";
+ reg = <0xf8000000 0x08000000>;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ direct_print {
+ label = "direct-print (blue)";
+ gpios = <&gpio 51 0>;
+ };
+
+ auto_focus {
+ label = "auto-focus (red)";
+ gpios = <&gpio 55 0>;
+ };
+ };
+};
+
+&timer2 {
+ status = "okay";
+};
diff --git a/arch/arm/mach-digic/Kconfig b/arch/arm/mach-digic/Kconfig
index 49ce44a..d25c3b3 100644
--- a/arch/arm/mach-digic/Kconfig
+++ b/arch/arm/mach-digic/Kconfig
@@ -3,6 +3,13 @@ if ARCH_DIGIC
choice
prompt "camera type"
+config MACH_CANON_A1100
+ bool "Canon PowerShot A1100 IS"
+
endchoice
+config ARCH_TEXT_BASE
+ hex
+ default 0x00001900 if MACH_CANON_A1100
+
endif
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 07/11] ARM: add Canon A1100 ROM image generation
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (5 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 06/11] ARM: DIGIC: add Canon PowerShot A1100 IS support Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 08/11] ARM: DIGIC: add canon-a1100_defconfig Antony Pavlov
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
.gitignore | 1 +
Makefile | 2 +-
arch/arm/Makefile | 10 ++++++++++
scripts/canon-a1100-image | 10 ++++++++++
4 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index ddeb7b1..a62e08c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,6 +47,7 @@ barebox.map
barebox.kwb
barebox.kwbuart
barebox.efi
+barebox.canon-a1100.bin
barebox-flash-image
System.map
Module.symvers
diff --git a/Makefile b/Makefile
index 3d08818..1ec0bfd 100644
--- a/Makefile
+++ b/Makefile
@@ -994,7 +994,7 @@ CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \
scripts/bareboxenv-target barebox-flash-image \
barebox.srec barebox.s5p barebox.ubl barebox.zynq \
barebox.uimage barebox.spi barebox.kwb barebox.kwbuart \
- barebox.efi
+ barebox.efi barebox.canon-a1100.bin
# Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config include2 usr/include
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 1b0d7fe..337aef1 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -185,6 +185,16 @@ ifeq ($(machine-y),zynq)
KBUILD_IMAGE := barebox.zynq
endif
+quiet_cmd_canon_a1100_image = DD $@
+ cmd_canon_a1100_image = scripts/canon-a1100-image $< $@ || \
+ echo "WARNING: Couldn't create Canon A1100 image due to previous errors."
+barebox.canon-a1100.bin: $(KBUILD_BINARY) FORCE
+ $(call if_changed,canon_a1100_image)
+
+ifeq ($(CONFIG_MACH_CANON_A1100),y)
+KBUILD_IMAGE := barebox.canon-a1100.bin
+endif
+
KWBIMAGE_OPTS = \
-c -i $(srctree)/$(BOARD)/kwbimage.cfg -d $(TEXT_BASE) -e $(TEXT_BASE)
diff --git a/scripts/canon-a1100-image b/scripts/canon-a1100-image
new file mode 100755
index 0000000..6c08d74
--- /dev/null
+++ b/scripts/canon-a1100-image
@@ -0,0 +1,10 @@
+#!/bin/bash -e
+
+IFILE=$1
+OFILE=$2
+
+dd if=/dev/zero bs=4M count=1 of=$OFILE 2>/dev/null
+dd if=$IFILE of=$OFILE conv=notrunc 2>/dev/null
+
+# 0xffff0000: fe 3f f0 ea b 0xffc00000
+echo -n -e "\xfe\x3f\xf0\xea" | dd of=$OFILE bs=64K seek=63 conv=notrunc 2>/dev/null
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 08/11] ARM: DIGIC: add canon-a1100_defconfig
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (6 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 07/11] ARM: add Canon A1100 ROM image generation Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 09/11] Documentation: add QEMU Canon A1100 barebox mini-howto Antony Pavlov
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/arm/configs/canon-a1100_defconfig | 56 ++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/arch/arm/configs/canon-a1100_defconfig b/arch/arm/configs/canon-a1100_defconfig
new file mode 100644
index 0000000..5c1e195
--- /dev/null
+++ b/arch/arm/configs/canon-a1100_defconfig
@@ -0,0 +1,56 @@
+CONFIG_BUILTIN_DTB=y
+CONFIG_BUILTIN_DTB_NAME="canon-a1100"
+CONFIG_ARCH_DIGIC=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_PBL_IMAGE=y
+CONFIG_IMAGE_COMPRESSION_LZ4=y
+CONFIG_TEXT_BASE=0x00300000
+CONFIG_MALLOC_SIZE=0x200000
+CONFIG_PROMPT="canon-a1100 > "
+CONFIG_GLOB=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+# CONFIG_DEFAULT_ENVIRONMENT is not set
+CONFIG_DEBUG_LL=y
+CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_MEMINFO=y
+# CONFIG_CMD_BOOTM is not set
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_GO=y
+CONFIG_CMD_LOADY=y
+# CONFIG_CMD_MOUNT is not set
+# CONFIG_CMD_UMOUNT is not set
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_GLOBAL=y
+CONFIG_CMD_MD5SUM=y
+# CONFIG_CMD_PWD is not set
+CONFIG_CMD_SHA1SUM=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_SLEEP=y
+# CONFIG_CMD_CLEAR is not set
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MM=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_LED=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OFTREE=y
+CONFIG_OFDEVICE=y
+CONFIG_DRIVER_SERIAL_DIGIC=y
+# CONFIG_SPI is not set
+CONFIG_MTD=y
+# CONFIG_MTD_WRITE is not set
+CONFIG_DRIVER_CFI=y
+# CONFIG_DRIVER_CFI_BANK_WIDTH_1 is not set
+CONFIG_CLOCKSOURCE_DUMMY=y
+CONFIG_CLOCKSOURCE_DUMMY_RATE=2000
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_GPIO_OF=y
+CONFIG_GPIO_DIGIC=y
+CONFIG_ZLIB=y
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 09/11] Documentation: add QEMU Canon A1100 barebox mini-howto
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (7 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 08/11] ARM: DIGIC: add canon-a1100_defconfig Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 10/11] ARM: add Canon A1100 DISKBOOT.BIN image generation stuff Antony Pavlov
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
Documentation/boards/digic.rst | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Documentation/boards/digic.rst b/Documentation/boards/digic.rst
new file mode 100644
index 0000000..e2c49b6
--- /dev/null
+++ b/Documentation/boards/digic.rst
@@ -0,0 +1,16 @@
+Canon DIGIC
+===========
+
+Canon PowerShot A1100 IS
+------------------------
+
+Running barebox on QEMU
+^^^^^^^^^^^^^^^^^^^^^^^
+
+QEMU supports Canon A1100 camera emulation since version 2.0.
+
+Usage::
+
+ $ qemu-system-arm -M canon-a1100 \
+ -nographic -monitor null -serial stdio \
+ -bios barebox.canon-a1100.bin
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 10/11] ARM: add Canon A1100 DISKBOOT.BIN image generation stuff
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (8 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 09/11] Documentation: add QEMU Canon A1100 barebox mini-howto Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-28 21:15 ` [PATCH v2 11/11] Documentation: add real Canon A1100 camera barebox mini-howto Antony Pavlov
2014-07-29 13:20 ` [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Sascha Hauer
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
This commit makes it possible to run barebox on real
Canon A1100 camera.
The 'dancingbits' utility imported from CHDK software;
see http://chdk.wikia.com/ for details.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
.gitignore | 1 +
Makefile | 2 +-
arch/arm/Makefile | 8 +++++-
scripts/.gitignore | 1 +
scripts/Makefile | 1 +
scripts/dancingbits.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
scripts/dancingbits.h | 20 +++++++++++++
scripts/mkdiskboot | 13 +++++++++
8 files changed, 121 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index a62e08c..39e10b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@ barebox.kwb
barebox.kwbuart
barebox.efi
barebox.canon-a1100.bin
+DISKBOOT-A1100.BIN
barebox-flash-image
System.map
Module.symvers
diff --git a/Makefile b/Makefile
index 1ec0bfd..932bd4a 100644
--- a/Makefile
+++ b/Makefile
@@ -994,7 +994,7 @@ CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \
scripts/bareboxenv-target barebox-flash-image \
barebox.srec barebox.s5p barebox.ubl barebox.zynq \
barebox.uimage barebox.spi barebox.kwb barebox.kwbuart \
- barebox.efi barebox.canon-a1100.bin
+ barebox.efi barebox.canon-a1100.bin DISKBOOT-A1100.BIN
# Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config include2 usr/include
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 337aef1..6960397 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -191,8 +191,14 @@ quiet_cmd_canon_a1100_image = DD $@
barebox.canon-a1100.bin: $(KBUILD_BINARY) FORCE
$(call if_changed,canon_a1100_image)
+quiet_cmd_canon_a1100_diskboot_image = DB $@
+ cmd_canon_a1100_diskboot_image = scripts/mkdiskboot $< $@ || \
+ echo "WARNING: Couldn't create Canon A1100 DISKBOOT image due to previous errors."
+DISKBOOT-A1100.BIN: $(KBUILD_BINARY) FORCE
+ $(call if_changed,canon_a1100_diskboot_image)
+
ifeq ($(CONFIG_MACH_CANON_A1100),y)
-KBUILD_IMAGE := barebox.canon-a1100.bin
+KBUILD_IMAGE := barebox.canon-a1100.bin DISKBOOT-A1100.BIN
endif
KWBIMAGE_OPTS = \
diff --git a/scripts/.gitignore b/scripts/.gitignore
index fddc04b..09d0611 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -1,5 +1,6 @@
bareboxenv
bin2c
+dancingbits
fix_size
gen_netx_image
kallsyms
diff --git a/scripts/Makefile b/scripts/Makefile
index 9c77680..3d92228 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -11,6 +11,7 @@ hostprogs-y += bareboxenv
hostprogs-y += bareboxcrc32
hostprogs-y += kernel-install
hostprogs-$(CONFIG_KALLSYMS) += kallsyms
+hostprogs-$(CONFIG_ARCH_DIGIC) += dancingbits
hostprogs-$(CONFIG_ARCH_MVEBU) += kwbimage kwboot
hostprogs-$(CONFIG_ARCH_NETX) += gen_netx_image
hostprogs-$(CONFIG_ARCH_OMAP) += omap_signGP mk-am3xxx-spi-image
diff --git a/scripts/dancingbits.c b/scripts/dancingbits.c
new file mode 100644
index 0000000..7d3c2b6
--- /dev/null
+++ b/scripts/dancingbits.c
@@ -0,0 +1,77 @@
+/*
+ * make an image bootable for latest cams
+ * (c) 2008 chr
+ *
+ * GPL v3+
+ *
+ * Why make things easy if complex sells better?
+ */
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "dancingbits.h"
+
+unsigned char dance(unsigned char allbest, int fudgey);
+
+#define GHOST 0x400
+#define BARNEY 0x00
+
+int main(int whim, char **reyalp) {
+ FILE *jeff666, *jucifer;
+ unsigned char *ewavr;
+ int oldgit;
+
+ if (whim != 4) {
+ printf("usage: <in file> <out file> <version>\n");
+ exit(1);
+ }
+
+ jeff666 = fopen(reyalp[1], "rb");
+ if (jeff666 == NULL) {
+ printf("Error open %s: %s\n", reyalp[1], strerror(errno));
+ exit(1);
+ }
+ jucifer = fopen(reyalp[2], "w+b");
+ if (jucifer == NULL) {
+ printf("Error open %s: %s\n", reyalp[2], strerror(errno));
+ exit(1);
+ }
+ oldgit = atoi(reyalp[3]);
+ if (oldgit < 1 || oldgit > VITALY) {
+ printf("Error version must be between 1 and %d, not %s\n", VITALY,reyalp[3]);
+ exit(1);
+ }
+ oldgit-=1;
+
+ fputc(BARNEY, jucifer);
+ ewavr = malloc(GHOST);
+
+ int grand, hacki = 0;
+ int phox = fread(ewavr, 1, GHOST, jeff666);
+ while (phox > 0) {
+ for (grand=0; grand<phox; grand+=8) {
+ unsigned char fe50[8];
+ for (hacki=0; hacki<8; hacki++) {
+ // fe50[hacki] = dance(ewavr[grand + _chr_[hacki]], grand+hacki);
+ fe50[_chr_[oldgit][hacki]] = dance(ewavr[grand + hacki], grand+hacki);
+ }
+ fwrite(fe50, 1, 8, jucifer);
+ }
+ phox = fread(ewavr, 1, GHOST, jeff666);
+ }
+ fclose(jeff666);
+ fclose(jucifer);
+ free(ewavr);
+ exit(0);
+}
+
+unsigned char dance(unsigned char allbest, int fudgey) {
+ if ((fudgey % 3) !=0)
+ return allbest ^ 0xff;
+ if ((fudgey & 1) == 0)
+ return allbest ^ 0xa0;
+ return (allbest >> 4) | (allbest << 4);
+}
diff --git a/scripts/dancingbits.h b/scripts/dancingbits.h
new file mode 100644
index 0000000..787f85f
--- /dev/null
+++ b/scripts/dancingbits.h
@@ -0,0 +1,20 @@
+
+// Dancing bits data for encoding diskboot.bin file
+// Used by dancingbits.c and finsig_dryos.c
+
+#define VITALY 12
+unsigned char _chr_[VITALY][8] = {
+ { 4,6,1,0,7,2,5,3 }, // original flavor
+ { 5,3,6,1,2,7,0,4 }, // nacho cheese sx200is, ixus100_sd780, ixu95_sd1200, a1100, d10
+ { 2,5,0,4,6,1,3,7 }, // mesquite bbq ixus200_sd980, sx20 (dryos r39)
+ { 4,7,3,2,6,5,0,1 }, // cool ranch a3100 (dryos r43)
+ { 3,2,7,5,1,4,6,0 }, // cajun chicken s95, g12, sx30 (dryos r45)
+ { 0,4,2,7,3,6,5,1 }, // spicy wasabi sx220, sx230, ixus310 (dryos r47)
+ { 7,1,5,3,0,6,4,2 }, // sea salt & vinegar sx40hs, sx150is (dryos r49)
+ { 6,3,1,0,5,7,2,4 }, // spicy habenaro sx260hs (dryos r50)
+ { 1,0,4,6,2,3,7,5 }, // tapatio hot sauce sx160is (dryos r51)
+ { 3,6,7,2,4,5,1,0 }, // blazin' jalapeno a1400 (dryos r52)
+ { 0,2,6,3,1,4,7,5 }, // guacamole sx510hs (dryos r52)
+ { 2,7,0,6,3,1,5,4 }, // (dryos r54)
+ };
+
diff --git a/scripts/mkdiskboot b/scripts/mkdiskboot
new file mode 100755
index 0000000..d7d62d2
--- /dev/null
+++ b/scripts/mkdiskboot
@@ -0,0 +1,13 @@
+#!/bin/bash -e
+
+IFILE=$1
+OFILE=$2
+
+TFILE=$(mktemp)
+
+dd if=/dev/zero of=$TFILE bs=1k count=128 2>/dev/null
+dd if=$IFILE of=$TFILE conv=notrunc 2>/dev/null
+
+scripts/dancingbits $TFILE $OFILE 2
+
+rm -f $TFILE
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 11/11] Documentation: add real Canon A1100 camera barebox mini-howto
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (9 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 10/11] ARM: add Canon A1100 DISKBOOT.BIN image generation stuff Antony Pavlov
@ 2014-07-28 21:15 ` Antony Pavlov
2014-07-29 13:20 ` [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Sascha Hauer
11 siblings, 0 replies; 13+ messages in thread
From: Antony Pavlov @ 2014-07-28 21:15 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
Documentation/boards/digic.rst | 53 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/Documentation/boards/digic.rst b/Documentation/boards/digic.rst
index e2c49b6..50a6ee8 100644
--- a/Documentation/boards/digic.rst
+++ b/Documentation/boards/digic.rst
@@ -14,3 +14,56 @@ Usage::
$ qemu-system-arm -M canon-a1100 \
-nographic -monitor null -serial stdio \
-bios barebox.canon-a1100.bin
+
+
+Running barebox on real camera
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Install CHDK firmware on SD-card (see http://chdk.wikia.com/wiki/CHDK_For_Newbies_-_How_To_Install and http://chdk.wikia.com/wiki/A1100).
+
+Make your SD-card bootable (see http://chdk.wikia.com/wiki/Prepare_your_SD_card).
+
+Build barebox: you will get the ``DISKBOOT-A1100.BIN`` file.
+
+Overwrite CHDK boot file on your SD-card (``DISKBOOT.BIN``)
+with the barebox ``DISKBOOT-A1100.BIN`` file.
+
+Lock your SD-card (use small switch on the card).
+**It is obligatory!**
+
+Insert the SD-card into your camera.
+Close your camera's SD-card slot.
+
+
+Turn your camera on (press the 'Playback mode' button).
+Barebox will run; it will use the serial port for console
+(see http://chdk.wikia.com/wiki/UART for details on A1100
+UART connection).
+
+
+LED script
+~~~~~~~~~~
+
+If you have no oppotunity to use camera's serial port then
+you can use leds for checking barebox.
+
+Enable ``CONFIG_DEFAULT_ENVIRONMENT`` in the ``.config``
+and set ``CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/canon-a1100/env"``.
+
+Use this ``arch/arm/boards/canon-600d/env/bin/init``::
+
+ #!/bin/sh
+
+ # use "direct print" led (blue)
+ LED=0
+
+ DELAY=300
+
+ for i in 1 2 3; do
+ led $LED 1
+ msleep $DELAY
+ led $LED 0
+ msleep $DELAY
+ done
+
+After barebox start the camera's blue led will blink.
--
2.0.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS
2014-07-28 21:15 [PATCH v2 00/11] ARM: add support for Canon DIGIC chips and Canon PowerShot A1100 IS Antony Pavlov
` (10 preceding siblings ...)
2014-07-28 21:15 ` [PATCH v2 11/11] Documentation: add real Canon A1100 camera barebox mini-howto Antony Pavlov
@ 2014-07-29 13:20 ` Sascha Hauer
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2014-07-29 13:20 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Tue, Jul 29, 2014 at 01:15:19AM +0400, Antony Pavlov wrote:
> Changes since v1:
>
> * fix reset_cpu();
> * add real Canon A1100 camera support.
>
> DIGIC is Canon Inc.'s name for a family of SoC
> for digital cameras and camcorders.
>
> See http://en.wikipedia.org/wiki/DIGIC for details.
>
> There is no publicly available specification for
> DIGIC chips. All information about DIGIC chip
> internals is based on reverse engineering efforts
> made by CHDK (http://chdk.wikia.com) and
> Magic Lantern (http://www.magiclantern.fm) projects
> contributors.
>
> Also this patch series adds initial support for Canon
> PowerShot A1100 IS compact camera (it is my only camera
> with connected UART interface). As the DIGIC-based cameras
> differences mostly are unsignificant (e.g. RAM-size,
> ROM type and size, GPIO usage) the other compact
> and DSLR cameras support can be easely added.
>
> One can easely run barebox for Canon A1100 using QEMU version 2.0
> or newer.
>
> This patchseries uses some patches already submitted to maillist:
>
> * clean barebox.zynq
> * treewide: drop Doxygen stuff
Applied this series up to 9/11 since I'm quite unsure if it's allowed
to include a GPLv3+ tool into a GPLv2 project.
There are some ways out of this situation:
- Ask the author to relicense it under GPLv2+
- rewrite the tool
- Use it as external tool
- Convince me that it's allowed ;)
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread