mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC 0/8] barebox on Canon cameras: serial console and dts support
@ 2013-08-26  4:57 Antony Pavlov
  2013-08-26  4:57 ` [RFC 1/8] ARM: add very initial support for Canon DIGIC chips Antony Pavlov
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 UTC (permalink / raw)
  To: barebox

Please don't commit the patches!

This patch series introduce support
for Canon DIGIC4-based cameras.

Changes since the previous (2013-08-04) version:
 * serial console support! (tested on Canon PowerShot A1100 only)
   * Y-Modem works!
 * gpio driver;
 * the serial and gpio driver have device tree support.

With serial console support barebox is a handy tool
for Canon DIGIC register map exploration.

Supported cameras:

 * Canon PowerShot A1100;
 * Canon EOS 600D;
 * Canon EOS Magic Lantern qemu-based emulator.

Very short Instruction
======================

***************************************************
*                                                 *
* THIS IS DANGEROUS AND MIGHT DAMAGE YOUR CAMERA. *
*  NO WARRANTIES.  NO GUARANTEES.  DO NOT TAUNT.  *
*                                                 *
***************************************************

The recommended ARM toolchain for barebox and Magic Lantern
build is 'gcc-arm-embedded'
see https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q2-update

1. Canon EOS 600D DSLR
----------------------

1.1 Install Magic Lantern firmware on a SD-card
 (see http://magiclantern.wikia.com/wiki/Unified/Install#First-time_installation)

1.2 Download and build barebox
    $ git clone -b next.digic.20130826 https://github.com/frantony/barebox barebox.digic
    $ cd barebox.digic
    $ export ARCH=arm
    $ export CROSS_COMPILE=<your_ARM_toolchain_prefix>
    $ make canon-600d_defconfig
    $ make

You will get the 'arch/arm/pbl/zbarebox.bin' file.

1.3 Overwrite Magic Lantern boot file on your 600D SD-card with the 'zbarebox.bin' file.
E.g., if your SD-card is mounted to the '/mnt/sd' dir, then

    $ sudo cp arch/arm/pbl/zbarebox.bin /mnt/sd/autoexec.bin

1.4 Insert SD-card into your camera.

1.5 Close your camera's SD-card slot.

1.6 Just after SD-card slot closing the barebox will start.
If all going well the SD-card led start blink.

1.7 Uninstall barebox
Remove battery from your camera and erase the 'autoexec.bin'
file from your SD-card.

2. Canon EOS emulator
---------------------

2.1 Download Magic Lantern sources

$ hg clone https://bitbucket.org/hudson/magic-lantern
$ cd magic-lantern

2.2 Setup your build environment

E.g., for Debian Linux:

$ cat > Makefile.user
RST2LATEX=rst2latex
PYTHON=python

GCC_VERSION=
CROSS_COMPILE=<your_ARM_toolchain_prefix>
<ctrl-d>
$

2.3 Buld Magic Lantern for 600D

$ make 600D

If all going well you can try qemu.

2.4 Bulding qemu

 $ cd contrib/qemu
 $ ./install.sh

 ...

 Use install.sh prompt:
  1) Compile QEMU
  2) Grab a copy of the Canon firmware
  3) Enable CONFIG_QEMU=y in your Makefile.user

2.5 Go to your qemu dir and start emulation with ./run_ml_600D.sh
The script will build the 'autoexec.bin' and 'qemu-helper.bin'

2.6 Build barebox image (see paragraph 1.2 Download and build barebox).

2.7 Copy zbarebox.bin to autoexec.bin in your qemu dir.

2.8 run qemu manually in qemu dir:

  <path-to-the-eos-qemu>/qemu-system-arm -M ML-600D

3. Canon PowerShot A1100 IS
---------------------------
Installing to the A1100 camera is a bit tricky as you need
"encrypt" barebox image.

3.1 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).

3.2 Make your SD-card bootable
 (see http://chdk.wikia.com/wiki/Prepare_your_SD_card)

3.3 Download and build barebox
    $ git clone -b next.digic.20130826 https://github.com/frantony/barebox barebox.digic
    $ cd barebox.digic
    $ export ARCH=arm
    $ export CROSS_COMPILE=<your_ARM_toolchain_prefix>
    $ make canon-a1100_defconfig
    $ make

You will get the 'arch/arm/pbl/zbarebox.bin' file.

3.4 Download CHDK sources

    $ git clone https://github.com/c10ud/CHDK.git
    $ cd CHDK

3.5 Build the 'dancingbits' encoder
    $ cd tools
    $ cc -o dancingbits dancingbits.c

3.6 encode your barebox image

Go to your barebox dir

3.6.1 Make zbarebox.bin > 128K; camera don't like small binaries :)

    $ dd if=/dev/zero bs=1k count=128 >> arch/arm/pbl/zbarebox.bin

3.6.2 encode

    $ <path-to-dancingbits> arch/arm/pbl/zbarebox.bin DISKBOOT.BIN 2

3.7 Overwrite CHDK boot file on your SD-card with the 'DISKBOOT.BIN' file.

3.9 Lock your SD-card (use small switch on the card).

3.10 Insert the SD-card into your camera.
Close your camera's SD-card slot.

3.11 Turn your camera on.
If all going well the 'direct print' led start blink.

3.12 Uninstall barebox
Remove battery from your camera and erase the 'DISKBOOT.BIN'
file from your SD-card.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  2013-08-26 13:20   ` Jason Cooper
  2013-08-26  4:57 ` [RFC 2/8] serial: add driver for Canon DIGIC UART Antony Pavlov
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 UTC (permalink / raw)
  To: barebox

TODO: the clocksource driver need improvement!

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/arm/Kconfig                            |  9 ++++
 arch/arm/Makefile                           |  1 +
 arch/arm/dts/digic4.dtsi                    | 24 +++++++++++
 arch/arm/mach-digic/Kconfig                 | 11 +++++
 arch/arm/mach-digic/Makefile                |  2 +
 arch/arm/mach-digic/core.c                  | 24 +++++++++++
 arch/arm/mach-digic/csrc-timer.c            | 67 +++++++++++++++++++++++++++++
 arch/arm/mach-digic/include/mach/debug_ll.h | 40 +++++++++++++++++
 arch/arm/mach-digic/include/mach/digic4.h   | 29 +++++++++++++
 arch/arm/mach-digic/include/mach/gpio.h     |  1 +
 10 files changed, 208 insertions(+)
 create mode 100644 arch/arm/dts/digic4.dtsi
 create mode 100644 arch/arm/mach-digic/Kconfig
 create mode 100644 arch/arm/mach-digic/Makefile
 create mode 100644 arch/arm/mach-digic/core.c
 create mode 100644 arch/arm/mach-digic/csrc-timer.c
 create mode 100644 arch/arm/mach-digic/include/mach/debug_ll.h
 create mode 100644 arch/arm/mach-digic/include/mach/digic4.h
 create mode 100644 arch/arm/mach-digic/include/mach/gpio.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 687acca..42cae36 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -54,6 +54,14 @@ config ARCH_CLPS711X
 	select GPIOLIB
 	select MFD_SYSCON
 
+config ARCH_DIGIC
+	bool "Canon DIGIC-based cameras"
+	select CPU_32v5
+	select HAS_DEBUG_LL
+	select GPIOLIB
+	help
+	  Support for Canon's digital cameras that use the DIGIC4 chip.
+
 config ARCH_EP93XX
 	bool "Cirrus Logic EP93xx"
 	select CPU_ARM920T
@@ -173,6 +181,7 @@ source arch/arm/cpu/Kconfig
 source arch/arm/mach-at91/Kconfig
 source arch/arm/mach-bcm2835/Kconfig
 source arch/arm/mach-clps711x/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 590a0d8..99929eb 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -54,6 +54,7 @@ AFLAGS   += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
 machine-$(CONFIG_ARCH_AT91)		:= at91
 machine-$(CONFIG_ARCH_BCM2835)		:= bcm2835
 machine-$(CONFIG_ARCH_CLPS711X)		:= clps711x
+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..8304bbe
--- /dev/null
+++ b/arch/arm/dts/digic4.dtsi
@@ -0,0 +1,24 @@
+/include/ "skeleton.dtsi"
+
+/ {
+	compatible = "canon,digic4";
+
+	uart: uart {
+		compatible = "canon,digic-serial";
+		reg = <0xc0800000 0x1c>;
+	};
+
+	/*
+	 * 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;
+	};
+};
diff --git a/arch/arm/mach-digic/Kconfig b/arch/arm/mach-digic/Kconfig
new file mode 100644
index 0000000..878a1a9
--- /dev/null
+++ b/arch/arm/mach-digic/Kconfig
@@ -0,0 +1,11 @@
+if ARCH_DIGIC
+
+choice
+	prompt "camera type"
+
+endchoice
+
+config DIGIC_CSRC_TIMER
+	bool
+
+endif
diff --git a/arch/arm/mach-digic/Makefile b/arch/arm/mach-digic/Makefile
new file mode 100644
index 0000000..1d7cb72
--- /dev/null
+++ b/arch/arm/mach-digic/Makefile
@@ -0,0 +1,2 @@
+obj-y += core.o
+obj-$(CONFIG_DIGIC_CSRC_TIMER) += csrc-timer.o
diff --git a/arch/arm/mach-digic/core.c b/arch/arm/mach-digic/core.c
new file mode 100644
index 0000000..a442633
--- /dev/null
+++ b/arch/arm/mach-digic/core.c
@@ -0,0 +1,24 @@
+/*
+ * 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)
+{
+	unreachable();
+}
+EXPORT_SYMBOL(reset_cpu);
diff --git a/arch/arm/mach-digic/csrc-timer.c b/arch/arm/mach-digic/csrc-timer.c
new file mode 100644
index 0000000..9ae33c4
--- /dev/null
+++ b/arch/arm/mach-digic/csrc-timer.c
@@ -0,0 +1,67 @@
+/*
+ * 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 <init.h>
+#include <clock.h>
+#include <io.h>
+
+#include <mach/digic4.h>
+
+#define DIGIC_TIMER_CLOCK 1000000
+
+#define DIGIC_TIMER_CONTROL 0x00
+#define DIGIC_TIMER_VALUE 0x0c
+
+static void *digic_timer_base;
+
+static uint64_t dummy_cs_read(void)
+{
+	return (uint64_t)(0xffff - readl(digic_timer_base + DIGIC_TIMER_VALUE));
+}
+
+static struct clocksource dummy_cs = {
+	.read	= dummy_cs_read,
+	.mask   = CLOCKSOURCE_MASK(16),
+};
+
+static int clocksource_init(void)
+{
+	clocks_calc_mult_shift(&dummy_cs.mult, &dummy_cs.shift,
+		DIGIC_TIMER_CLOCK, NSEC_PER_SEC, 1);
+
+	digic_timer_base = (void *)DIGIC4_TIMER2;
+
+	/* disable timer */
+	writel(0x80000000, digic_timer_base + DIGIC_TIMER_CONTROL);
+
+	/* magic values... divider? */
+	writel(0x00000002, digic_timer_base + 0x04);
+	writel(0x00000003, digic_timer_base + 0x14);
+
+	/* max counter value */
+	writel(0x0000ffff, digic_timer_base + 0x08);
+
+	init_clock(&dummy_cs);
+
+	/* enable timer */
+	writel(0x00000001, digic_timer_base + DIGIC_TIMER_CONTROL);
+	/* start timer */
+	writel(0x00000001, digic_timer_base + 0x10);
+
+	return 0;
+}
+core_initcall(clocksource_init);
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..5f4579e
--- /dev/null
+++ b/arch/arm/mach-digic/include/mach/debug_ll.h
@@ -0,0 +1,40 @@
+/*
+ * 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 __MACH_DEBUG_LL_H__
+#define __MACH_DEBUG_LL_H__
+
+#include <io.h>
+#include <mach/digic4.h>
+
+#define DEBUG_LL_UART         DIGIC4_UART
+
+/* Serial interface registers */
+#define DEBUG_LL_UART_TX         (DEBUG_LL_UART + 0x0)
+#define DEBUG_LL_UART_ST         (DEBUG_LL_UART + 0x14)
+ #define UART_ST_TX_RDY	2
+
+static inline void PUTC_LL(char ch)
+{
+	while (!(readl(DEBUG_LL_UART_ST) & UART_ST_TX_RDY))
+		; /* noop */
+
+	writel(0x06, DEBUG_LL_UART_ST);
+	writel(ch, DEBUG_LL_UART_TX);
+}
+
+#endif
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..c0e50a4
--- /dev/null
+++ b/arch/arm/mach-digic/include/mach/digic4.h
@@ -0,0 +1,29 @@
+/*
+ * 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
+
+#define DIGIC4_TIMER0	0xc0210000
+#define DIGIC4_TIMER1	0xc0210100
+#define DIGIC4_TIMER2	0xc0210200
+
+#define DIGIC4_GPIO(n)	(0xc0220000 + 4*n)
+
+#endif /* __DIGIC4_H__ */
diff --git a/arch/arm/mach-digic/include/mach/gpio.h b/arch/arm/mach-digic/include/mach/gpio.h
new file mode 100644
index 0000000..306ab4c
--- /dev/null
+++ b/arch/arm/mach-digic/include/mach/gpio.h
@@ -0,0 +1 @@
+#include <asm-generic/gpio.h>
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 2/8] serial: add driver for Canon DIGIC UART
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
  2013-08-26  4:57 ` [RFC 1/8] ARM: add very initial support for Canon DIGIC chips Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  2013-08-26 13:28   ` Jason Cooper
  2013-08-26  4:57 ` [RFC 3/8] gpio: add driver for Canon DIGIC Antony Pavlov
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 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 | 131 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 136 insertions(+)
 create mode 100644 drivers/serial/serial_digic.c

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 11fc155..541350d 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -122,4 +122,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 93790b5..485a3ef 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_DRIVER_SERIAL_PXA)			+= serial_pxa.o
 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_DIGIC)		+= serial_digic.o
diff --git a/drivers/serial/serial_digic.c b/drivers/serial/serial_digic.c
new file mode 100644
index 0000000..938172f
--- /dev/null
+++ b/drivers/serial/serial_digic.c
@@ -0,0 +1,131 @@
+/*
+ * 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 <init.h>
+#include <malloc.h>
+#include <io.h>
+
+/* Serial interface registers offsets */
+#define UART_TX	0x0
+#define UART_RX	0x4
+#define UART_ST	0x14
+ #define UART_ST_RX_RDY	1
+ #define UART_ST_TX_RDY	2
+
+/*
+ * 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 off)
+{
+	void *digic = cdev->dev->priv;
+
+	return readl(digic + off);
+}
+
+static inline void digic_serial_writel(struct console_device *cdev, uint32_t val,
+			  uint32_t off)
+{
+	void *digic = cdev->dev->priv;
+
+	writel(val, digic + off);
+}
+
+static int digic_serial_setbaudrate(struct console_device *cdev, int baudrate)
+{
+	/* FIXME: empty */
+
+	return 0;
+}
+
+static void digic_serial_putc(struct console_device *cdev, char c)
+{
+	while (!(digic_serial_readl(cdev, UART_ST) & UART_ST_TX_RDY))
+		; /* noop */
+
+	digic_serial_writel(cdev, 0x06, UART_ST);
+	digic_serial_writel(cdev, c, UART_TX);
+}
+
+static int digic_serial_getc(struct console_device *cdev)
+{
+	while (!(digic_serial_readl(cdev, UART_ST) & UART_ST_RX_RDY))
+		; /* noop */
+
+	digic_serial_writel(cdev, 0x01, UART_ST);
+
+	return digic_serial_readl(cdev, UART_RX);
+}
+
+static int digic_serial_tstc(struct console_device *cdev)
+{
+	return ((digic_serial_readl(cdev, UART_ST) & UART_ST_RX_RDY) != 0);
+
+	/*
+	 * Canon folks use additional check, something like this:
+	 *
+	 *		if (digic_serial_readl(cdev, UART_ST) & 0x38) {
+	 *			digic_serial_writel(cdev, 0x38, UART_ST);
+	 *			return 0;
+	 *		}
+	 *
+	 * But I know nothing about these magic bits in the status regster...
+	 *
+	*/
+}
+
+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->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+	cdev->tstc = &digic_serial_tstc;
+	cdev->putc = &digic_serial_putc;
+	cdev->getc = &digic_serial_getc;
+	cdev->setbrg = &digic_serial_setbaudrate;
+
+	/* FIXME: need digic_init_port(cdev); */
+
+	console_register(cdev);
+
+	return 0;
+}
+
+static __maybe_unused struct of_device_id digic_serial_dt_ids[] = {
+	{
+		.compatible = "canon,digic-serial",
+	}, {
+		/* sentinel */
+	}
+};
+
+static struct driver_d digic_serial_driver = {
+	.name  = "digic-serial",
+	.probe = digic_serial_probe,
+	.of_compatible = DRV_OF_COMPAT(digic_serial_dt_ids),
+};
+console_platform_driver(digic_serial_driver);
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 3/8] gpio: add driver for Canon DIGIC
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
  2013-08-26  4:57 ` [RFC 1/8] ARM: add very initial support for Canon DIGIC chips Antony Pavlov
  2013-08-26  4:57 ` [RFC 2/8] serial: add driver for Canon DIGIC UART Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  2013-08-26  4:57 ` [RFC 4/8] ARM: DIGIC: add Canon PowerShot A1100 IS support Antony Pavlov
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 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 | 176 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 181 insertions(+)
 create mode 100644 drivers/gpio/gpio-digic.c

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index d5ac532..f112db8 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 adb668f..c5cf58a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_GPIOLIB)		+= gpiolib.o
 
 obj-$(CONFIG_GPIO_BCM2835)	+= gpio-bcm2835.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_ORION)	+= gpio-orion.o
diff --git a/drivers/gpio/gpio-digic.c b/drivers/gpio/gpio-digic.c
new file mode 100644
index 0000000..82eef12
--- /dev/null
+++ b/drivers/gpio/gpio-digic.c
@@ -0,0 +1,176 @@
+/*
+ * 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;
+};
+
+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 val,
+			  uint32_t offset)
+{
+	writel(val, chip->base + 4 * offset);
+}
+
+static int digic_gpio_get_value(struct gpio_chip *gc, unsigned offset)
+{
+	struct digic_gpio_chip *chip = container_of(gc, struct 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 = container_of(gc, struct 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 = container_of(gc, struct 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 = container_of(gc, struct 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, 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 __init digic_gpio_init(void)
+{
+	return platform_driver_register(&digic_gpio_driver);
+}
+coredevice_initcall(digic_gpio_init);
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 4/8] ARM: DIGIC: add Canon PowerShot A1100 IS support
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
                   ` (2 preceding siblings ...)
  2013-08-26  4:57 ` [RFC 3/8] gpio: add driver for Canon DIGIC Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  2013-08-26  4:57 ` [RFC 5/8] ARM: DIGIC: add canon-a1100_defconfig Antony Pavlov
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 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/env/bin/init | 15 +++++++++++++++
 arch/arm/boards/canon-a1100/env/bin/zup  | 11 +++++++++++
 arch/arm/boards/canon-a1100/lowlevel.c   | 23 +++++++++++++++++++++++
 arch/arm/dts/canon-a1100.dts             | 26 ++++++++++++++++++++++++++
 arch/arm/mach-digic/Kconfig              |  8 ++++++++
 7 files changed, 85 insertions(+)
 create mode 100644 arch/arm/boards/canon-a1100/Makefile
 create mode 100644 arch/arm/boards/canon-a1100/env/bin/init
 create mode 100644 arch/arm/boards/canon-a1100/env/bin/zup
 create mode 100644 arch/arm/boards/canon-a1100/lowlevel.c
 create mode 100644 arch/arm/dts/canon-a1100.dts

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 38ef512..76f21be 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_CCMX51)			+= ccxmx51/
 obj-$(CONFIG_MACH_CFA10036)			+= crystalfontz-cfa10036/
 obj-$(CONFIG_MACH_CHUMBY)			+= chumby_falconwing/
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/env/bin/init b/arch/arm/boards/canon-a1100/env/bin/init
new file mode 100644
index 0000000..509643d
--- /dev/null
+++ b/arch/arm/boards/canon-a1100/env/bin/init
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+export PATH=/env/bin
+
+# 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
diff --git a/arch/arm/boards/canon-a1100/env/bin/zup b/arch/arm/boards/canon-a1100/env/bin/zup
new file mode 100644
index 0000000..84bfd2f
--- /dev/null
+++ b/arch/arm/boards/canon-a1100/env/bin/zup
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# on Canon PowerShot A1100 IS we can use 0x400000
+LOADADDR=0x400000
+IMGNAME=zbarebox.bin
+
+loady
+if [ -e $IMGNAME ]; then
+	memcpy -s $IMGNAME 0 $LOADADDR
+	go $LOADADDR
+fi
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..dfa1d72
--- /dev/null
+++ b/arch/arm/dts/canon-a1100.dts
@@ -0,0 +1,26 @@
+/dts-v1/;
+
+/include/ "digic4.dtsi"
+
+/ {
+	model = "Canon PowerShot A1100 IS";
+	compatible = "canon,a1100";
+
+	memory {
+		reg = <0x00000000 0x04000000>;
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		direct_print {
+			label = "direct-print led (blue)";
+			gpios = <&gpio 51 0>;
+		};
+
+		auto_focus {
+			label = "auto-focus led (red)";
+			gpios = <&gpio 55 0>;
+		};
+	};
+};
diff --git a/arch/arm/mach-digic/Kconfig b/arch/arm/mach-digic/Kconfig
index 878a1a9..557cad4 100644
--- a/arch/arm/mach-digic/Kconfig
+++ b/arch/arm/mach-digic/Kconfig
@@ -3,8 +3,16 @@ if ARCH_DIGIC
 choice
 	prompt "camera type"
 
+config MACH_CANON_A1100
+	bool "Canon PowerShot A1100 IS"
+	select DIGIC_CSRC_TIMER
+
 endchoice
 
+config ARCH_TEXT_BASE
+	hex
+	default 0x00001900 if MACH_CANON_A1100
+
 config DIGIC_CSRC_TIMER
 	bool
 
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 5/8] ARM: DIGIC: add canon-a1100_defconfig
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
                   ` (3 preceding siblings ...)
  2013-08-26  4:57 ` [RFC 4/8] ARM: DIGIC: add Canon PowerShot A1100 IS support Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  2013-08-26  4:57 ` [RFC 6/8] ARM: DIGIC: add csrc-dummy Antony Pavlov
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/arm/configs/canon-a1100_defconfig | 53 ++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 arch/arm/configs/canon-a1100_defconfig

diff --git a/arch/arm/configs/canon-a1100_defconfig b/arch/arm/configs/canon-a1100_defconfig
new file mode 100644
index 0000000..60deabd
--- /dev/null
+++ b/arch/arm/configs/canon-a1100_defconfig
@@ -0,0 +1,53 @@
+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_PBL_RELOCATABLE=y
+CONFIG_IMAGE_COMPRESSION_LZ4=y
+CONFIG_TEXT_BASE=0x00300000
+CONFIG_MALLOC_SIZE=0x200000
+CONFIG_PROMPT="canon> "
+CONFIG_LONGHELP=y
+CONFIG_GLOB=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_HUSH_GETOPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/canon-a1100/env"
+CONFIG_DEBUG_LL=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_GLOBAL=y
+# CONFIG_CMD_RM is not set
+# CONFIG_CMD_MKDIR is not set
+# CONFIG_CMD_RMDIR is not set
+# CONFIG_CMD_PWD is not set
+# CONFIG_CMD_MOUNT is not set
+# CONFIG_CMD_UMOUNT is not set
+# CONFIG_CMD_CLEAR is not set
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_LOADY=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_MM=y
+# CONFIG_CMD_BOOTM is not set
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_LED=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_DRIVER_SERIAL_DIGIC=y
+# CONFIG_SPI is not set
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_GPIO_OF=y
+CONFIG_GPIO_DIGIC=y
+CONFIG_ZLIB=y
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 6/8] ARM: DIGIC: add csrc-dummy
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
                   ` (4 preceding siblings ...)
  2013-08-26  4:57 ` [RFC 5/8] ARM: DIGIC: add canon-a1100_defconfig Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  2013-08-26  4:57 ` [RFC 7/8] ARM: DIGIC: add Canon EOS 600D support Antony Pavlov
  2013-08-26  4:57 ` [RFC 8/8] ARM: DIGIC: add canon-600d_defconfig Antony Pavlov
  7 siblings, 0 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 UTC (permalink / raw)
  To: barebox

The clocksource csrc-timer driver that uses DIGIC
hardware TIMER2 perfectrly works on Canon A1100,
but does not works on Canon EOS 600D.
IMHO we need additional timer initialisation.

This patch introduces a quick-and-dirty termporary
solution for this situation: a clocksource driver that
does not use any hardware at all.

Also this driver is very handy for running barebox
on Magic Lantern EOS qemu-based emulator as
the emulator does not realize timer counter register at all!

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/arm/mach-digic/Kconfig      |  4 ++++
 arch/arm/mach-digic/Makefile     |  1 +
 arch/arm/mach-digic/csrc-dummy.c | 49 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 arch/arm/mach-digic/csrc-dummy.c

diff --git a/arch/arm/mach-digic/Kconfig b/arch/arm/mach-digic/Kconfig
index 557cad4..b3de2d9 100644
--- a/arch/arm/mach-digic/Kconfig
+++ b/arch/arm/mach-digic/Kconfig
@@ -13,7 +13,11 @@ config ARCH_TEXT_BASE
 	hex
 	default 0x00001900 if MACH_CANON_A1100
 
+
 config DIGIC_CSRC_TIMER
 	bool
 
+config DIGIC_CSRC_DUMMY
+	bool
+
 endif
diff --git a/arch/arm/mach-digic/Makefile b/arch/arm/mach-digic/Makefile
index 1d7cb72..31e5ac1 100644
--- a/arch/arm/mach-digic/Makefile
+++ b/arch/arm/mach-digic/Makefile
@@ -1,2 +1,3 @@
 obj-y += core.o
 obj-$(CONFIG_DIGIC_CSRC_TIMER) += csrc-timer.o
+obj-$(CONFIG_DIGIC_CSRC_DUMMY) += csrc-dummy.o
diff --git a/arch/arm/mach-digic/csrc-dummy.c b/arch/arm/mach-digic/csrc-dummy.c
new file mode 100644
index 0000000..68c68a3
--- /dev/null
+++ b/arch/arm/mach-digic/csrc-dummy.c
@@ -0,0 +1,49 @@
+/*
+ * 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 <init.h>
+#include <clock.h>
+
+#include <stdio.h>
+
+static uint64_t dummy_counter;
+
+static uint64_t dummy_cs_read(void)
+{
+	dummy_counter += 2000;
+	return dummy_counter;
+}
+
+static struct clocksource dummy_cs = {
+	.read	= dummy_cs_read,
+	.mask   = CLOCKSOURCE_MASK(32),
+};
+
+static int clocksource_init(void)
+{
+	dummy_counter = 0;
+
+	clocks_calc_mult_shift(&dummy_cs.mult, &dummy_cs.shift,
+		100000000, NSEC_PER_SEC, 10);
+
+	printf("clocksource_init: mult=%08x, shift=%08x\n",
+			dummy_cs.mult, dummy_cs.shift);
+	init_clock(&dummy_cs);
+
+	return 0;
+}
+core_initcall(clocksource_init);
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 7/8] ARM: DIGIC: add Canon EOS 600D support
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
                   ` (5 preceding siblings ...)
  2013-08-26  4:57 ` [RFC 6/8] ARM: DIGIC: add csrc-dummy Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  2013-08-26  4:57 ` [RFC 8/8] ARM: DIGIC: add canon-600d_defconfig Antony Pavlov
  7 siblings, 0 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/arm/boards/Makefile                |  1 +
 arch/arm/boards/canon-600d/Makefile     |  1 +
 arch/arm/boards/canon-600d/env/bin/init | 17 +++++++++++++++++
 arch/arm/boards/canon-600d/env/bin/zup  | 11 +++++++++++
 arch/arm/boards/canon-600d/lowlevel.c   | 23 +++++++++++++++++++++++
 arch/arm/dts/canon-600d.dts             | 21 +++++++++++++++++++++
 arch/arm/mach-digic/Kconfig             |  5 +++++
 7 files changed, 79 insertions(+)
 create mode 100644 arch/arm/boards/canon-600d/Makefile
 create mode 100644 arch/arm/boards/canon-600d/env/bin/init
 create mode 100644 arch/arm/boards/canon-600d/env/bin/zup
 create mode 100644 arch/arm/boards/canon-600d/lowlevel.c
 create mode 100644 arch/arm/dts/canon-600d.dts

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 76f21be..bb95428 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_600D)			+= canon-600d/
 obj-$(CONFIG_MACH_CANON_A1100)			+= canon-a1100/
 obj-$(CONFIG_MACH_CCMX51)			+= ccxmx51/
 obj-$(CONFIG_MACH_CFA10036)			+= crystalfontz-cfa10036/
diff --git a/arch/arm/boards/canon-600d/Makefile b/arch/arm/boards/canon-600d/Makefile
new file mode 100644
index 0000000..b08c4a9
--- /dev/null
+++ b/arch/arm/boards/canon-600d/Makefile
@@ -0,0 +1 @@
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/canon-600d/env/bin/init b/arch/arm/boards/canon-600d/env/bin/init
new file mode 100644
index 0000000..478fd23
--- /dev/null
+++ b/arch/arm/boards/canon-600d/env/bin/init
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+export PATH=/env/bin
+
+# use "direct print" led (blue)
+LED=0
+
+DELAY=300
+
+md 0xF7FFFFF0+0x20
+
+for i in 1 2 3; do
+	led $LED 1
+	msleep $DELAY
+	led $LED 0
+	msleep $DELAY
+done
diff --git a/arch/arm/boards/canon-600d/env/bin/zup b/arch/arm/boards/canon-600d/env/bin/zup
new file mode 100644
index 0000000..84bfd2f
--- /dev/null
+++ b/arch/arm/boards/canon-600d/env/bin/zup
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# on Canon PowerShot A1100 IS we can use 0x400000
+LOADADDR=0x400000
+IMGNAME=zbarebox.bin
+
+loady
+if [ -e $IMGNAME ]; then
+	memcpy -s $IMGNAME 0 $LOADADDR
+	go $LOADADDR
+fi
diff --git a/arch/arm/boards/canon-600d/lowlevel.c b/arch/arm/boards/canon-600d/lowlevel.c
new file mode 100644
index 0000000..a588880
--- /dev/null
+++ b/arch/arm/boards/canon-600d/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_256M, 0);
+}
diff --git a/arch/arm/dts/canon-600d.dts b/arch/arm/dts/canon-600d.dts
new file mode 100644
index 0000000..ee1fa4e
--- /dev/null
+++ b/arch/arm/dts/canon-600d.dts
@@ -0,0 +1,21 @@
+/dts-v1/;
+
+/include/ "digic4.dtsi"
+
+/ {
+	model = "Canon EOS 600D";
+	compatible = "canon,eos600d";
+
+	memory {
+		reg = <0x00000000 0x10000000>;
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		sd_slot {
+			label = "sd-card activity led (red)";
+			gpios = <&gpio 77 0>;
+		};
+	};
+};
diff --git a/arch/arm/mach-digic/Kconfig b/arch/arm/mach-digic/Kconfig
index b3de2d9..31c4a90 100644
--- a/arch/arm/mach-digic/Kconfig
+++ b/arch/arm/mach-digic/Kconfig
@@ -7,11 +7,16 @@ config MACH_CANON_A1100
 	bool "Canon PowerShot A1100 IS"
 	select DIGIC_CSRC_TIMER
 
+config MACH_CANON_600D
+	bool "Canon EOS 600D"
+	select DIGIC_CSRC_DUMMY
+
 endchoice
 
 config ARCH_TEXT_BASE
 	hex
 	default 0x00001900 if MACH_CANON_A1100
+	default 0x00800000 if MACH_CANON_600D
 
 
 config DIGIC_CSRC_TIMER
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [RFC 8/8] ARM: DIGIC: add canon-600d_defconfig
  2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
                   ` (6 preceding siblings ...)
  2013-08-26  4:57 ` [RFC 7/8] ARM: DIGIC: add Canon EOS 600D support Antony Pavlov
@ 2013-08-26  4:57 ` Antony Pavlov
  7 siblings, 0 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26  4:57 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/arm/configs/canon-600d_defconfig | 54 +++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 arch/arm/configs/canon-600d_defconfig

diff --git a/arch/arm/configs/canon-600d_defconfig b/arch/arm/configs/canon-600d_defconfig
new file mode 100644
index 0000000..a8ff597
--- /dev/null
+++ b/arch/arm/configs/canon-600d_defconfig
@@ -0,0 +1,54 @@
+CONFIG_BUILTIN_DTB=y
+CONFIG_BUILTIN_DTB_NAME="canon-600d"
+CONFIG_ARCH_DIGIC=y
+CONFIG_MACH_CANON_600D=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_PBL_IMAGE=y
+CONFIG_PBL_RELOCATABLE=y
+CONFIG_IMAGE_COMPRESSION_LZ4=y
+CONFIG_TEXT_BASE=0x00300000
+CONFIG_MALLOC_SIZE=0x200000
+CONFIG_PROMPT="canon> "
+CONFIG_LONGHELP=y
+CONFIG_GLOB=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_HUSH_GETOPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/canon-600d/env"
+CONFIG_DEBUG_LL=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_GLOBAL=y
+# CONFIG_CMD_RM is not set
+# CONFIG_CMD_MKDIR is not set
+# CONFIG_CMD_RMDIR is not set
+# CONFIG_CMD_PWD is not set
+# CONFIG_CMD_MOUNT is not set
+# CONFIG_CMD_UMOUNT is not set
+# CONFIG_CMD_CLEAR is not set
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_LOADY=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_MM=y
+# CONFIG_CMD_BOOTM is not set
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_LED=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_DRIVER_SERIAL_DIGIC=y
+# CONFIG_SPI is not set
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_GPIO_OF=y
+CONFIG_GPIO_DIGIC=y
+CONFIG_ZLIB=y
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-26  4:57 ` [RFC 1/8] ARM: add very initial support for Canon DIGIC chips Antony Pavlov
@ 2013-08-26 13:20   ` Jason Cooper
  2013-08-26 18:51     ` Antony Pavlov
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Cooper @ 2013-08-26 13:20 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

Hi Antony,

On Mon, Aug 26, 2013 at 08:57:10AM +0400, Antony Pavlov wrote:
> TODO: the clocksource driver need improvement!
> 
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  arch/arm/Kconfig                            |  9 ++++
>  arch/arm/Makefile                           |  1 +
>  arch/arm/dts/digic4.dtsi                    | 24 +++++++++++
>  arch/arm/mach-digic/Kconfig                 | 11 +++++
>  arch/arm/mach-digic/Makefile                |  2 +
>  arch/arm/mach-digic/core.c                  | 24 +++++++++++
>  arch/arm/mach-digic/csrc-timer.c            | 67 +++++++++++++++++++++++++++++
>  arch/arm/mach-digic/include/mach/debug_ll.h | 40 +++++++++++++++++
>  arch/arm/mach-digic/include/mach/digic4.h   | 29 +++++++++++++
>  arch/arm/mach-digic/include/mach/gpio.h     |  1 +
>  10 files changed, 208 insertions(+)
>  create mode 100644 arch/arm/dts/digic4.dtsi
>  create mode 100644 arch/arm/mach-digic/Kconfig
>  create mode 100644 arch/arm/mach-digic/Makefile
>  create mode 100644 arch/arm/mach-digic/core.c
>  create mode 100644 arch/arm/mach-digic/csrc-timer.c
>  create mode 100644 arch/arm/mach-digic/include/mach/debug_ll.h
>  create mode 100644 arch/arm/mach-digic/include/mach/digic4.h
>  create mode 100644 arch/arm/mach-digic/include/mach/gpio.h
> 
...
> 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..5f4579e
> --- /dev/null
> +++ b/arch/arm/mach-digic/include/mach/debug_ll.h
> @@ -0,0 +1,40 @@
> +/*
> + * 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 __MACH_DEBUG_LL_H__
> +#define __MACH_DEBUG_LL_H__
> +
> +#include <io.h>
> +#include <mach/digic4.h>
> +
> +#define DEBUG_LL_UART         DIGIC4_UART
> +
> +/* Serial interface registers */
> +#define DEBUG_LL_UART_TX         (DEBUG_LL_UART + 0x0)
> +#define DEBUG_LL_UART_ST         (DEBUG_LL_UART + 0x14)
> + #define UART_ST_TX_RDY	2

leading whitespace, and perhaps use BIT() here.

> +
> +static inline void PUTC_LL(char ch)
> +{
> +	while (!(readl(DEBUG_LL_UART_ST) & UART_ST_TX_RDY))
> +		; /* noop */
> +
> +	writel(0x06, DEBUG_LL_UART_ST);

could you use a macro here for 0x06?

> +	writel(ch, DEBUG_LL_UART_TX);
> +}
> +
> +#endif

thx,

Jason.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 2/8] serial: add driver for Canon DIGIC UART
  2013-08-26  4:57 ` [RFC 2/8] serial: add driver for Canon DIGIC UART Antony Pavlov
@ 2013-08-26 13:28   ` Jason Cooper
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Cooper @ 2013-08-26 13:28 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Mon, Aug 26, 2013 at 08:57:11AM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  drivers/serial/Kconfig        |   4 ++
>  drivers/serial/Makefile       |   1 +
>  drivers/serial/serial_digic.c | 131 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 136 insertions(+)
>  create mode 100644 drivers/serial/serial_digic.c
> 
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 11fc155..541350d 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -122,4 +122,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 93790b5..485a3ef 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -17,3 +17,4 @@ obj-$(CONFIG_DRIVER_SERIAL_PXA)			+= serial_pxa.o
>  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_DIGIC)		+= serial_digic.o
> diff --git a/drivers/serial/serial_digic.c b/drivers/serial/serial_digic.c
> new file mode 100644
> index 0000000..938172f
> --- /dev/null
> +++ b/drivers/serial/serial_digic.c
> @@ -0,0 +1,131 @@
> +/*
> + * 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 <init.h>
> +#include <malloc.h>
> +#include <io.h>
> +
> +/* Serial interface registers offsets */
> +#define UART_TX	0x0
> +#define UART_RX	0x4
> +#define UART_ST	0x14
> + #define UART_ST_RX_RDY	1
> + #define UART_ST_TX_RDY	2

leading whitespace, BIT().

> +
> +/*
> + * 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 off)
> +{
> +	void *digic = cdev->dev->priv;
> +
> +	return readl(digic + off);
> +}
> +
> +static inline void digic_serial_writel(struct console_device *cdev, uint32_t val,
> +			  uint32_t off)
> +{
> +	void *digic = cdev->dev->priv;
> +
> +	writel(val, digic + off);
> +}
> +

> +static int digic_serial_setbaudrate(struct console_device *cdev, int baudrate)
> +{
> +	/* FIXME: empty */
> +
> +	return 0;
> +}

You don't need this, see below.

> +
> +static void digic_serial_putc(struct console_device *cdev, char c)
> +{
> +	while (!(digic_serial_readl(cdev, UART_ST) & UART_ST_TX_RDY))
> +		; /* noop */
> +
> +	digic_serial_writel(cdev, 0x06, UART_ST);
> +	digic_serial_writel(cdev, c, UART_TX);
> +}
> +
> +static int digic_serial_getc(struct console_device *cdev)
> +{
> +	while (!(digic_serial_readl(cdev, UART_ST) & UART_ST_RX_RDY))
> +		; /* noop */
> +
> +	digic_serial_writel(cdev, 0x01, UART_ST);
> +
> +	return digic_serial_readl(cdev, UART_RX);
> +}
> +
> +static int digic_serial_tstc(struct console_device *cdev)
> +{
> +	return ((digic_serial_readl(cdev, UART_ST) & UART_ST_RX_RDY) != 0);
> +
> +	/*
> +	 * Canon folks use additional check, something like this:
> +	 *
> +	 *		if (digic_serial_readl(cdev, UART_ST) & 0x38) {
> +	 *			digic_serial_writel(cdev, 0x38, UART_ST);
> +	 *			return 0;
> +	 *		}
> +	 *
> +	 * But I know nothing about these magic bits in the status regster...
> +	 *
> +	*/
> +}
> +
> +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->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
> +	cdev->tstc = &digic_serial_tstc;
> +	cdev->putc = &digic_serial_putc;
> +	cdev->getc = &digic_serial_getc;


> +	cdev->setbrg = &digic_serial_setbaudrate;

It's probably better to set this to NULL, since you don't know how
change the baud rate (and remove digic_serial_setbaudrate(), above).

thx,

Jason.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-26 13:20   ` Jason Cooper
@ 2013-08-26 18:51     ` Antony Pavlov
  2013-08-26 19:47       ` Jason Cooper
  0 siblings, 1 reply; 17+ messages in thread
From: Antony Pavlov @ 2013-08-26 18:51 UTC (permalink / raw)
  To: Jason Cooper; +Cc: barebox

On Mon, 26 Aug 2013 09:20:18 -0400
Jason Cooper <jason@lakedaemon.net> wrote:

> Hi Antony,
> 
> On Mon, Aug 26, 2013 at 08:57:10AM +0400, Antony Pavlov wrote:
> > TODO: the clocksource driver need improvement!
> > 
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> >  arch/arm/Kconfig                            |  9 ++++
> >  arch/arm/Makefile                           |  1 +
> >  arch/arm/dts/digic4.dtsi                    | 24 +++++++++++
> >  arch/arm/mach-digic/Kconfig                 | 11 +++++
> >  arch/arm/mach-digic/Makefile                |  2 +
> >  arch/arm/mach-digic/core.c                  | 24 +++++++++++
> >  arch/arm/mach-digic/csrc-timer.c            | 67 +++++++++++++++++++++++++++++
> >  arch/arm/mach-digic/include/mach/debug_ll.h | 40 +++++++++++++++++
> >  arch/arm/mach-digic/include/mach/digic4.h   | 29 +++++++++++++
> >  arch/arm/mach-digic/include/mach/gpio.h     |  1 +
> >  10 files changed, 208 insertions(+)
> >  create mode 100644 arch/arm/dts/digic4.dtsi
> >  create mode 100644 arch/arm/mach-digic/Kconfig
> >  create mode 100644 arch/arm/mach-digic/Makefile
> >  create mode 100644 arch/arm/mach-digic/core.c
> >  create mode 100644 arch/arm/mach-digic/csrc-timer.c
> >  create mode 100644 arch/arm/mach-digic/include/mach/debug_ll.h
> >  create mode 100644 arch/arm/mach-digic/include/mach/digic4.h
> >  create mode 100644 arch/arm/mach-digic/include/mach/gpio.h
> > 
> ...
> > 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..5f4579e
> > --- /dev/null
> > +++ b/arch/arm/mach-digic/include/mach/debug_ll.h
> > @@ -0,0 +1,40 @@
> > +/*
> > + * 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 __MACH_DEBUG_LL_H__
> > +#define __MACH_DEBUG_LL_H__
> > +
> > +#include <io.h>
> > +#include <mach/digic4.h>
> > +
> > +#define DEBUG_LL_UART         DIGIC4_UART
> > +
> > +/* Serial interface registers */
> > +#define DEBUG_LL_UART_TX         (DEBUG_LL_UART + 0x0)
> > +#define DEBUG_LL_UART_ST         (DEBUG_LL_UART + 0x14)
> > + #define UART_ST_TX_RDY	2
> 
> leading whitespace, and perhaps use BIT() here.

The leading whitespace is put here intentionally to distinguish register address macros
and bit fields macros.

> > +
> > +static inline void PUTC_LL(char ch)
> > +{
> > +	while (!(readl(DEBUG_LL_UART_ST) & UART_ST_TX_RDY))
> > +		; /* noop */
> > +
> > +	writel(0x06, DEBUG_LL_UART_ST);
> 
> could you use a macro here for 0x06?

It is not so easy. See comments in serial driver: there is no public documentation
on Canon Digic chips. This driver is result of reverse engineering.
I have no complete information about the bitfield meaning. In this situation
it's very difficult to invent adequate names for the bitfield macros.
E.g. I have given the DEBUG_LL_UART_ST name to the register (I mean STATUS register).
But now I see that It is not just a status register but a control register too.
Just now I prefere to keep the names and constants as-is.

Moreover the situation with digic timers is worse as I don't know meaning of most bitfields :)

> > +	writel(ch, DEBUG_LL_UART_TX);
> > +}
> > +
> > +#endif
> 
> thx,
> 
> Jason.


-- 
-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-26 18:51     ` Antony Pavlov
@ 2013-08-26 19:47       ` Jason Cooper
  2013-08-26 23:32         ` Sebastian Hesselbarth
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Cooper @ 2013-08-26 19:47 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Mon, Aug 26, 2013 at 10:51:48PM +0400, Antony Pavlov wrote:
> On Mon, 26 Aug 2013 09:20:18 -0400
> Jason Cooper <jason@lakedaemon.net> wrote:
> 
> > Hi Antony,
> > 
> > On Mon, Aug 26, 2013 at 08:57:10AM +0400, Antony Pavlov wrote:
> > > TODO: the clocksource driver need improvement!
> > > 
> > > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > > ---
> > >  arch/arm/Kconfig                            |  9 ++++
> > >  arch/arm/Makefile                           |  1 +
> > >  arch/arm/dts/digic4.dtsi                    | 24 +++++++++++
> > >  arch/arm/mach-digic/Kconfig                 | 11 +++++
> > >  arch/arm/mach-digic/Makefile                |  2 +
> > >  arch/arm/mach-digic/core.c                  | 24 +++++++++++
> > >  arch/arm/mach-digic/csrc-timer.c            | 67 +++++++++++++++++++++++++++++
> > >  arch/arm/mach-digic/include/mach/debug_ll.h | 40 +++++++++++++++++
> > >  arch/arm/mach-digic/include/mach/digic4.h   | 29 +++++++++++++
> > >  arch/arm/mach-digic/include/mach/gpio.h     |  1 +
> > >  10 files changed, 208 insertions(+)
> > >  create mode 100644 arch/arm/dts/digic4.dtsi
> > >  create mode 100644 arch/arm/mach-digic/Kconfig
> > >  create mode 100644 arch/arm/mach-digic/Makefile
> > >  create mode 100644 arch/arm/mach-digic/core.c
> > >  create mode 100644 arch/arm/mach-digic/csrc-timer.c
> > >  create mode 100644 arch/arm/mach-digic/include/mach/debug_ll.h
> > >  create mode 100644 arch/arm/mach-digic/include/mach/digic4.h
> > >  create mode 100644 arch/arm/mach-digic/include/mach/gpio.h
> > > 
> > ...
> > > 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..5f4579e
> > > --- /dev/null
> > > +++ b/arch/arm/mach-digic/include/mach/debug_ll.h
> > > @@ -0,0 +1,40 @@
> > > +/*
> > > + * 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 __MACH_DEBUG_LL_H__
> > > +#define __MACH_DEBUG_LL_H__
> > > +
> > > +#include <io.h>
> > > +#include <mach/digic4.h>
> > > +
> > > +#define DEBUG_LL_UART         DIGIC4_UART
> > > +
> > > +/* Serial interface registers */
> > > +#define DEBUG_LL_UART_TX         (DEBUG_LL_UART + 0x0)
> > > +#define DEBUG_LL_UART_ST         (DEBUG_LL_UART + 0x14)
> > > + #define UART_ST_TX_RDY	2
> > 
> > leading whitespace, and perhaps use BIT() here.
> 
> The leading whitespace is put here intentionally to distinguish register address macros
> and bit fields macros.

CodingStyle doesn't spell it out explicitly, however:

$ git grep -c '^[ \t]#define'
arch/arm/mach-omap/include/mach/omap3-silicon.h:2
arch/mips/mach-xburst/include/mach/jz4750d_regs.h:27
include/scsi.h:1

Shows that it isn't widely used.  In fact, the above examples probably
snuck in and should be cleaned up.  git blame shows:

  637b3aa7 USB mass storage device driver initial implementation
  8b85ac8c MIPS: XBurst: add JZ4755 CPU support
  7e4e7b0d omap3: Add macros to extract hawkeye and version

> 
> > > +
> > > +static inline void PUTC_LL(char ch)
> > > +{
> > > +	while (!(readl(DEBUG_LL_UART_ST) & UART_ST_TX_RDY))
> > > +		; /* noop */
> > > +
> > > +	writel(0x06, DEBUG_LL_UART_ST);
> > 
> > could you use a macro here for 0x06?
> 
> It is not so easy. See comments in serial driver: there is no public documentation
> on Canon Digic chips. 

bummer.  It's a shame we can't match it up against another IP.  I doubt
the entire SoC was developed in a vacuum.

> This driver is result of reverse engineering.
> I have no complete information about the bitfield meaning. In this situation
> it's very difficult to invent adequate names for the bitfield macros.
> E.g. I have given the DEBUG_LL_UART_ST name to the register (I mean STATUS register).
> But now I see that It is not just a status register but a control register too.
> Just now I prefere to keep the names and constants as-is.

I agree, we don't want to guess.  Perhaps a comment to that effect?

thx,

Jason.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-26 19:47       ` Jason Cooper
@ 2013-08-26 23:32         ` Sebastian Hesselbarth
  2013-08-27  1:46           ` Jason Cooper
  2013-08-27  7:00           ` Jürgen Beisert
  0 siblings, 2 replies; 17+ messages in thread
From: Sebastian Hesselbarth @ 2013-08-26 23:32 UTC (permalink / raw)
  To: Jason Cooper; +Cc: barebox

On 08/26/2013 09:47 PM, Jason Cooper wrote:
> On Mon, Aug 26, 2013 at 10:51:48PM +0400, Antony Pavlov wrote:
>> On Mon, 26 Aug 2013 09:20:18 -0400
>> Jason Cooper <jason@lakedaemon.net> wrote:
>>> On Mon, Aug 26, 2013 at 08:57:10AM +0400, Antony Pavlov wrote:
>>>> +/* Serial interface registers */
>>>> +#define DEBUG_LL_UART_TX         (DEBUG_LL_UART + 0x0)
>>>> +#define DEBUG_LL_UART_ST         (DEBUG_LL_UART + 0x14)
>>>> + #define UART_ST_TX_RDY	2
>>>
>>> leading whitespace, and perhaps use BIT() here.
>>
>> The leading whitespace is put here intentionally to distinguish register address macros
>> and bit fields macros.
>
> CodingStyle doesn't spell it out explicitly, however:
>
> $ git grep -c '^[ \t]#define'

Jason,

you should have used

git grep -c '^#[ \t]define'

It is in fact quite common to distinguish address offset macros
and bit macros by adding a space, but between '#' and 'define'.

Sebastian

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-26 23:32         ` Sebastian Hesselbarth
@ 2013-08-27  1:46           ` Jason Cooper
  2013-08-27  4:57             ` Antony Pavlov
  2013-08-27  7:00           ` Jürgen Beisert
  1 sibling, 1 reply; 17+ messages in thread
From: Jason Cooper @ 2013-08-27  1:46 UTC (permalink / raw)
  To: Sebastian Hesselbarth; +Cc: barebox

On Tue, Aug 27, 2013 at 01:32:49AM +0200, Sebastian Hesselbarth wrote:
> On 08/26/2013 09:47 PM, Jason Cooper wrote:
> >On Mon, Aug 26, 2013 at 10:51:48PM +0400, Antony Pavlov wrote:
> >>On Mon, 26 Aug 2013 09:20:18 -0400
> >>Jason Cooper <jason@lakedaemon.net> wrote:
> >>>On Mon, Aug 26, 2013 at 08:57:10AM +0400, Antony Pavlov wrote:
> >>>>+/* Serial interface registers */
> >>>>+#define DEBUG_LL_UART_TX         (DEBUG_LL_UART + 0x0)
> >>>>+#define DEBUG_LL_UART_ST         (DEBUG_LL_UART + 0x14)
> >>>>+ #define UART_ST_TX_RDY	2
> >>>
> >>>leading whitespace, and perhaps use BIT() here.
> >>
> >>The leading whitespace is put here intentionally to distinguish register address macros
> >>and bit fields macros.
> >
> >CodingStyle doesn't spell it out explicitly, however:
> >
> >$ git grep -c '^[ \t]#define'
> 
> Jason,
> 
> you should have used
> 
> git grep -c '^#[ \t]define'
> 
> It is in fact quite common to distinguish address offset macros
> and bit macros by adding a space, but between '#' and 'define'.

fair enough, I'll admit it's a personal bias. :-P I like everything
lined up vertically so that differences from line to line stand out
more.  But that's just me, and it's not my code, so I'll drop it.

thx,

Jason.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-27  1:46           ` Jason Cooper
@ 2013-08-27  4:57             ` Antony Pavlov
  0 siblings, 0 replies; 17+ messages in thread
From: Antony Pavlov @ 2013-08-27  4:57 UTC (permalink / raw)
  To: Jason Cooper; +Cc: barebox

On Mon, 26 Aug 2013 21:46:48 -0400
Jason Cooper <jason@lakedaemon.net> wrote:

> On Tue, Aug 27, 2013 at 01:32:49AM +0200, Sebastian Hesselbarth wrote:
> > On 08/26/2013 09:47 PM, Jason Cooper wrote:
> > >On Mon, Aug 26, 2013 at 10:51:48PM +0400, Antony Pavlov wrote:
> > >>On Mon, 26 Aug 2013 09:20:18 -0400
> > >>Jason Cooper <jason@lakedaemon.net> wrote:
> > >>>On Mon, Aug 26, 2013 at 08:57:10AM +0400, Antony Pavlov wrote:
> > >>>>+/* Serial interface registers */
> > >>>>+#define DEBUG_LL_UART_TX         (DEBUG_LL_UART + 0x0)
> > >>>>+#define DEBUG_LL_UART_ST         (DEBUG_LL_UART + 0x14)
> > >>>>+ #define UART_ST_TX_RDY	2
> > >>>
> > >>>leading whitespace, and perhaps use BIT() here.
> > >>
> > >>The leading whitespace is put here intentionally to distinguish register address macros
> > >>and bit fields macros.
> > >
> > >CodingStyle doesn't spell it out explicitly, however:
> > >
> > >$ git grep -c '^[ \t]#define'
> > 
> > Jason,
> > 
> > you should have used
> > 
> > git grep -c '^#[ \t]define'
> > 
> > It is in fact quite common to distinguish address offset macros
> > and bit macros by adding a space, but between '#' and 'define'.

Thanks, Sebastian! You are right. I have just misplaced the space :)

> fair enough, I'll admit it's a personal bias. :-P I like everything
> lined up vertically so that differences from line to line stand out
> more.  But that's just me, and it's not my code, so I'll drop it.

Anyway I have a plan to rework these DEBUG_LL-related macros as they dublicate
the macros in the digic-serial driver :)

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [RFC 1/8] ARM: add very initial support for Canon DIGIC chips
  2013-08-26 23:32         ` Sebastian Hesselbarth
  2013-08-27  1:46           ` Jason Cooper
@ 2013-08-27  7:00           ` Jürgen Beisert
  1 sibling, 0 replies; 17+ messages in thread
From: Jürgen Beisert @ 2013-08-27  7:00 UTC (permalink / raw)
  To: barebox; +Cc: Jason Cooper

On Tuesday 27 August 2013 01:32:49 Sebastian Hesselbarth wrote:
> [...]
> you should have used
>
> git grep -c '^#[ \t]define'
>
> It is in fact quite common to distinguish address offset macros
> and bit macros by adding a space, but between '#' and 'define'.

From the GCC webpage:
"Preprocessing directives are recognized in traditional C only when their 
leading # appears in the first column. There can be no whitespace between the 
beginning of the line and the #."

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2013-08-27  6:59 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-26  4:57 [RFC 0/8] barebox on Canon cameras: serial console and dts support Antony Pavlov
2013-08-26  4:57 ` [RFC 1/8] ARM: add very initial support for Canon DIGIC chips Antony Pavlov
2013-08-26 13:20   ` Jason Cooper
2013-08-26 18:51     ` Antony Pavlov
2013-08-26 19:47       ` Jason Cooper
2013-08-26 23:32         ` Sebastian Hesselbarth
2013-08-27  1:46           ` Jason Cooper
2013-08-27  4:57             ` Antony Pavlov
2013-08-27  7:00           ` Jürgen Beisert
2013-08-26  4:57 ` [RFC 2/8] serial: add driver for Canon DIGIC UART Antony Pavlov
2013-08-26 13:28   ` Jason Cooper
2013-08-26  4:57 ` [RFC 3/8] gpio: add driver for Canon DIGIC Antony Pavlov
2013-08-26  4:57 ` [RFC 4/8] ARM: DIGIC: add Canon PowerShot A1100 IS support Antony Pavlov
2013-08-26  4:57 ` [RFC 5/8] ARM: DIGIC: add canon-a1100_defconfig Antony Pavlov
2013-08-26  4:57 ` [RFC 6/8] ARM: DIGIC: add csrc-dummy Antony Pavlov
2013-08-26  4:57 ` [RFC 7/8] ARM: DIGIC: add Canon EOS 600D support Antony Pavlov
2013-08-26  4:57 ` [RFC 8/8] ARM: DIGIC: add canon-600d_defconfig Antony Pavlov

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