Date: Tue, 21 Feb 2012 00:26:52 +0000 (UTC) From: Damjan Marion <dmarion@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r231947 - in projects/armv6/sys: arm/ti boot/fdt/dts Message-ID: <201202210026.q1L0Qq65074100@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dmarion Date: Tue Feb 21 00:26:52 2012 New Revision: 231947 URL: http://svn.freebsd.org/changeset/base/231947 Log: Introduce new FDT attribute for ti_i2c driver to avoid possible issues with selecting right clock. Approved by: cognet (mentor) Modified: projects/armv6/sys/arm/ti/ti_i2c.c projects/armv6/sys/arm/ti/ti_prcm.h projects/armv6/sys/boot/fdt/dts/pandaboard.dts Modified: projects/armv6/sys/arm/ti/ti_i2c.c ============================================================================== --- projects/armv6/sys/arm/ti/ti_i2c.c Mon Feb 20 21:10:14 2012 (r231946) +++ projects/armv6/sys/arm/ti/ti_i2c.c Tue Feb 21 00:26:52 2012 (r231947) @@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$"); struct ti_i2c_softc { device_t sc_dev; + uint32_t device_id; struct resource* sc_irq_res; struct resource* sc_mem_res; device_t sc_iicbus; @@ -812,7 +813,7 @@ ti_i2c_activate(device_t dev) * * 1. Enable the functional and interface clocks (see Section 18.3.1.1.1). */ - clk = I2C1_CLK + device_get_unit(dev); + clk = I2C0_CLK + sc->device_id; err = ti_prcm_clk_enable(clk); if (err) return (err); @@ -982,7 +983,7 @@ ti_i2c_deactivate(device_t dev) } /* Finally disable the functional and interface clocks */ - clk = I2C1_CLK + device_get_unit(dev); + clk = I2C0_CLK + sc->device_id; ti_prcm_clk_disable(clk); return; @@ -1026,11 +1027,21 @@ static int ti_i2c_attach(device_t dev) { struct ti_i2c_softc *sc = device_get_softc(dev); + phandle_t node; + pcell_t did; int err; int rid; sc->sc_dev = dev; + /* Get the i2c device id from FDT */ + node = ofw_bus_get_node(dev); + if ((OF_getprop(node, "i2c-device-id", &did, sizeof(did))) <= 0) { + device_printf(dev, "missing i2c-device-id attribute in FDT\n"); + return (ENXIO); + } + sc->device_id = fdt32_to_cpu(did); + TI_I2C_LOCK_INIT(sc); /* Get the memory resource for the register mapping */ Modified: projects/armv6/sys/arm/ti/ti_prcm.h ============================================================================== --- projects/armv6/sys/arm/ti/ti_prcm.h Mon Feb 20 21:10:14 2012 (r231946) +++ projects/armv6/sys/arm/ti/ti_prcm.h Tue Feb 21 00:26:52 2012 (r231947) @@ -48,7 +48,7 @@ typedef enum { * on these clocks as they are enabled by default. */ SYS_CLK = 1, - + /* The MPU (ARM) core clock */ MPU_CLK = 20, @@ -58,13 +58,14 @@ typedef enum { MMC3_CLK, MMC4_CLK, MMC5_CLK, - + /* I2C modules */ - I2C1_CLK = 200, + I2C0_CLK = 200, + I2C1_CLK, I2C2_CLK, I2C3_CLK, I2C4_CLK, - + /* USB module(s) */ USBTLL_CLK = 300, USBHSHOST_CLK, @@ -75,13 +76,13 @@ typedef enum { USBP2_UTMI_CLK, USBP1_HSIC_CLK, USBP2_HSIC_CLK, - + /* UART modules */ UART1_CLK = 400, UART2_CLK, UART3_CLK, UART4_CLK, - + /* General purpose timer modules */ GPTIMER1_CLK = 500, GPTIMER2_CLK, @@ -95,14 +96,14 @@ typedef enum { GPTIMER10_CLK, GPTIMER11_CLK, GPTIMER12_CLK, - + /* McBSP module(s) */ MCBSP1_CLK = 600, MCBSP2_CLK, MCBSP3_CLK, MCBSP4_CLK, MCBSP5_CLK, - + /* General purpose I/O modules */ GPIO1_CLK = 700, GPIO2_CLK, @@ -110,12 +111,12 @@ typedef enum { GPIO4_CLK, GPIO5_CLK, GPIO6_CLK, - + /* sDMA module */ SDMA_CLK = 800, INVALID_CLK_IDENT - + } clk_ident_t; /* @@ -124,7 +125,7 @@ typedef enum { typedef enum { SYSCLK_CLK, /* System clock */ EXT_CLK, - + F32KHZ_CLK, /* 32KHz clock */ F48MHZ_CLK, /* 48MHz clock */ F64MHZ_CLK, /* 64MHz clock */ @@ -135,7 +136,7 @@ typedef enum { struct ti_clock_dev { /* The profile of the timer */ clk_ident_t id; - + /* A bunch of callbacks associated with the clock device */ int (*clk_activate)(struct ti_clock_dev *clkdev); int (*clk_deactivate)(struct ti_clock_dev *clkdev); @@ -144,7 +145,6 @@ struct ti_clock_dev { int (*clk_accessible)(struct ti_clock_dev *clkdev); int (*clk_get_source_freq)(struct ti_clock_dev *clkdev, unsigned int *freq); - }; int ti_prcm_clk_valid(clk_ident_t clk); Modified: projects/armv6/sys/boot/fdt/dts/pandaboard.dts ============================================================================== --- projects/armv6/sys/boot/fdt/dts/pandaboard.dts Mon Feb 20 21:10:14 2012 (r231946) +++ projects/armv6/sys/boot/fdt/dts/pandaboard.dts Tue Feb 21 00:26:52 2012 (r231947) @@ -151,7 +151,7 @@ reg =< 0x48070000 0x100 >; interrupts = <88>; interrupt-parent = <&GIC>; - + i2c-device-id = <1>; }; sdma@x48070000 {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202210026.q1L0Qq65074100>