Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/imx add support imx6 I2C Controller
details: https://anonhg.NetBSD.org/src/rev/4c148b356f71
branches: trunk
changeset: 332743:4c148b356f71
user: ryo <ryo%NetBSD.org@localhost>
date: Tue Oct 07 09:36:09 2014 +0000
description:
add support imx6 I2C Controller
diffstat:
sys/arch/arm/imx/files.imx6 | 8 +++-
sys/arch/arm/imx/imx6_ccm.c | 26 ++++++++-----
sys/arch/arm/imx/imx6_ccmvar.h | 12 +++--
sys/arch/arm/imx/imx6_i2c.c | 83 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 113 insertions(+), 16 deletions(-)
diffs (217 lines):
diff -r ec6fb618673a -r 4c148b356f71 sys/arch/arm/imx/files.imx6
--- a/sys/arch/arm/imx/files.imx6 Tue Oct 07 09:32:47 2014 +0000
+++ b/sys/arch/arm/imx/files.imx6 Tue Oct 07 09:36:09 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.imx6,v 1.3 2014/10/06 10:15:40 ryo Exp $
+# $NetBSD: files.imx6,v 1.4 2014/10/07 09:36:09 ryo Exp $
#
# Configuration info for the Freescale i.MX6
#
@@ -61,6 +61,12 @@
attach imxiomux at axi
file arch/arm/imx/imx6_iomux.c imxiomux
+# iMX iic Controler
+device imxi2c: i2cbus
+attach imxi2c at axi
+file arch/arm/imx/imxi2c.c imxi2c
+file arch/arm/imx/imx6_i2c.c imxi2c
+
# iMX UART
device imxuart
attach imxuart at axi
diff -r ec6fb618673a -r 4c148b356f71 sys/arch/arm/imx/imx6_ccm.c
--- a/sys/arch/arm/imx/imx6_ccm.c Tue Oct 07 09:32:47 2014 +0000
+++ b/sys/arch/arm/imx/imx6_ccm.c Tue Oct 07 09:36:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: imx6_ccm.c,v 1.2 2014/10/06 10:27:13 ryo Exp $ */
+/* $NetBSD: imx6_ccm.c,v 1.3 2014/10/07 09:36:09 ryo Exp $ */
/*
* Copyright (c) 2010-2012, 2014 Genetec Corporation. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.2 2014/10/06 10:27:13 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.3 2014/10/07 09:36:09 ryo Exp $");
#include "opt_imx.h"
#include "opt_imx6clk.h"
@@ -167,13 +167,13 @@
imx6_get_clock(IMX6CLK_AXI));
aprint_verbose_dev(self, "IMX6CLK_USDHC1=%d\n",
- imx6_get_clock(IMX6CLK_USDHC1_CLK_ROOT));
+ imx6_get_clock(IMX6CLK_USDHC1));
aprint_verbose_dev(self, "IMX6CLK_USDHC2=%d\n",
- imx6_get_clock(IMX6CLK_USDHC2_CLK_ROOT));
+ imx6_get_clock(IMX6CLK_USDHC2));
aprint_verbose_dev(self, "IMX6CLK_USDHC3=%d\n",
- imx6_get_clock(IMX6CLK_USDHC3_CLK_ROOT));
+ imx6_get_clock(IMX6CLK_USDHC3));
aprint_verbose_dev(self, "IMX6CLK_USDHC4=%d\n",
- imx6_get_clock(IMX6CLK_USDHC4_CLK_ROOT));
+ imx6_get_clock(IMX6CLK_USDHC4));
}
static int
@@ -630,28 +630,28 @@
}
break;
- case IMX6CLK_USDHC1_CLK_ROOT:
+ case IMX6CLK_USDHC1:
v = imx6_ccm_read(CCM_CSCMR1);
freq = imx6_get_clock((v & CCM_CSCMR1_USDHC1_CLK_SEL) ?
IMX6CLK_PLL2_PFD0 : IMX6CLK_PLL2_PFD2);
v = imx6_ccm_read(CCM_CSCDR1);
freq = freq / (__SHIFTOUT(v, CCM_CSCDR1_USDHC1_PODF) + 1);
break;
- case IMX6CLK_USDHC2_CLK_ROOT:
+ case IMX6CLK_USDHC2:
v = imx6_ccm_read(CCM_CSCMR1);
freq = imx6_get_clock((v & CCM_CSCMR1_USDHC2_CLK_SEL) ?
IMX6CLK_PLL2_PFD0 : IMX6CLK_PLL2_PFD2);
v = imx6_ccm_read(CCM_CSCDR1);
freq = freq / (__SHIFTOUT(v, CCM_CSCDR1_USDHC2_PODF) + 1);
break;
- case IMX6CLK_USDHC3_CLK_ROOT:
+ case IMX6CLK_USDHC3:
v = imx6_ccm_read(CCM_CSCMR1);
freq = imx6_get_clock((v & CCM_CSCMR1_USDHC3_CLK_SEL) ?
IMX6CLK_PLL2_PFD0 : IMX6CLK_PLL2_PFD2);
v = imx6_ccm_read(CCM_CSCDR1);
freq = freq / (__SHIFTOUT(v, CCM_CSCDR1_USDHC3_PODF) + 1);
break;
- case IMX6CLK_USDHC4_CLK_ROOT:
+ case IMX6CLK_USDHC4:
v = imx6_ccm_read(CCM_CSCMR1);
freq = imx6_get_clock((v & CCM_CSCMR1_USDHC4_CLK_SEL) ?
IMX6CLK_PLL2_PFD0 : IMX6CLK_PLL2_PFD2);
@@ -659,6 +659,12 @@
freq = freq / (__SHIFTOUT(v, CCM_CSCDR1_USDHC4_PODF) + 1);
break;
+ case IMX6CLK_PERCLK:
+ freq = imx6_get_clock(IMX6CLK_IPG);
+ v = imx6_ccm_read(CCM_CSCMR1);
+ freq = freq / (__SHIFTOUT(v, CCM_CSCMR1_PERCLK_PODF) + 1);
+ break;
+
default:
aprint_error_dev(ccm_softc->sc_dev,
"clock %d: not supported yet\n", clk);
diff -r ec6fb618673a -r 4c148b356f71 sys/arch/arm/imx/imx6_ccmvar.h
--- a/sys/arch/arm/imx/imx6_ccmvar.h Tue Oct 07 09:32:47 2014 +0000
+++ b/sys/arch/arm/imx/imx6_ccmvar.h Tue Oct 07 09:36:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: imx6_ccmvar.h,v 1.1 2014/09/25 05:05:28 ryo Exp $ */
+/* $NetBSD: imx6_ccmvar.h,v 1.2 2014/10/07 09:36:09 ryo Exp $ */
/*
* Copyright (c) 2012 Genetec Corporation. All rights reserved.
* Written by Hashimoto Kenichi for Genetec Corporation.
@@ -54,10 +54,12 @@
IMX6CLK_MMDC_CH0,
IMX6CLK_MMDC_CH1,
- IMX6CLK_USDHC1_CLK_ROOT,
- IMX6CLK_USDHC2_CLK_ROOT,
- IMX6CLK_USDHC3_CLK_ROOT,
- IMX6CLK_USDHC4_CLK_ROOT,
+ IMX6CLK_USDHC1,
+ IMX6CLK_USDHC2,
+ IMX6CLK_USDHC3,
+ IMX6CLK_USDHC4,
+
+ IMX6CLK_PERCLK,
};
uint32_t imx6_get_clock(enum imx6_clock);
diff -r ec6fb618673a -r 4c148b356f71 sys/arch/arm/imx/imx6_i2c.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/imx/imx6_i2c.c Tue Oct 07 09:36:09 2014 +0000
@@ -0,0 +1,83 @@
+/* $NetBSD: imx6_i2c.c,v 1.1 2014/10/07 09:36:09 ryo Exp $ */
+
+/*
+ * Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * i.MX6 I2C Controller
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: imx6_i2c.c,v 1.1 2014/10/07 09:36:09 ryo Exp $");
+
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/param.h>
+
+#include <arm/imx/imx6var.h>
+#include <arm/imx/imx6_reg.h>
+#include <arm/imx/imx6_ccmvar.h>
+#include <arm/imx/imxi2cvar.h>
+
+/* ARGSUSED */
+int
+imxi2c_match(device_t parent __unused, struct cfdata *match __unused, void *aux)
+{
+ struct axi_attach_args *aa;
+
+ aa = aux;
+
+ switch (aa->aa_addr) {
+ case IMX6_AIPS2_BASE + AIPS2_I2C1_BASE:
+ case IMX6_AIPS2_BASE + AIPS2_I2C2_BASE:
+ case IMX6_AIPS2_BASE + AIPS2_I2C3_BASE:
+ return 1;
+ }
+
+ return 0;
+}
+
+/* ARGSUSED */
+void
+imxi2c_attach(device_t parent __unused, device_t self, void *aux)
+{
+ struct imxi2c_softc *sc;
+ struct axi_attach_args *aa;
+ struct i2cbus_attach_args iba;
+
+ aa = aux;
+ sc = device_private(self);
+
+ imxi2c_attach_common(parent, self, aa->aa_iot, aa->aa_addr, aa->aa_size,
+ aa->aa_irq, 0);
+
+ imxi2c_set_freq(self, imx6_get_clock(IMX6CLK_PERCLK), 400000);
+
+ memset(&iba, 0, sizeof(iba));
+ iba.iba_tag = &sc->sc_i2c;
+ config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print);
+}
+
Home |
Main Index |
Thread Index |
Old Index