diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-05 12:59:29 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-05 12:59:29 +0200 |
commit | 038307cb5e6e0e655ec251f561959afd2ef1bfd1 (patch) | |
tree | 6e1cf4b97c46565e21ff7e9ef2d222d281bc972c /arch/ppc | |
parent | 4c9d8da6fea91a49476b86bb92996a0480478537 (diff) | |
parent | 075209e8f3a78f5ae5e5c239ab3120db263b51c2 (diff) | |
download | barebox-038307cb5e6e0e655ec251f561959afd2ef1bfd1.tar.gz barebox-038307cb5e6e0e655ec251f561959afd2ef1bfd1.tar.xz |
Merge branch 'for-next/i2c'
Diffstat (limited to 'arch/ppc')
-rw-r--r-- | arch/ppc/boards/freescale-p2020rdb/p2020rdb.c | 13 | ||||
-rw-r--r-- | arch/ppc/configs/p2020rdb_defconfig | 3 | ||||
-rw-r--r-- | arch/ppc/include/asm/fsl_i2c.h | 86 | ||||
-rw-r--r-- | arch/ppc/mach-mpc85xx/include/mach/clock.h (renamed from arch/ppc/mach-mpc85xx/include/mach/clocks.h) | 1 | ||||
-rw-r--r-- | arch/ppc/mach-mpc85xx/include/mach/immap_85xx.h | 3 | ||||
-rw-r--r-- | arch/ppc/mach-mpc85xx/speed.c | 11 | ||||
-rw-r--r-- | arch/ppc/mach-mpc85xx/time.c | 2 |
7 files changed, 30 insertions, 89 deletions
diff --git a/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c b/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c index 494ef257cf..c5fae0d7aa 100644 --- a/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c +++ b/arch/ppc/boards/freescale-p2020rdb/p2020rdb.c @@ -26,6 +26,7 @@ #include <driver.h> #include <ns16550.h> #include <types.h> +#include <i2c/i2c.h> #include <partition.h> #include <memory.h> #include <asm/cache.h> @@ -34,7 +35,7 @@ #include <mach/mpc85xx.h> #include <mach/mmu.h> #include <mach/immap_85xx.h> -#include <mach/clocks.h> +#include <mach/clock.h> #include <mach/early_udelay.h> #define VSC7385_RST_SET 0x00080000 @@ -61,10 +62,20 @@ #define SYSCLK_50 50000000 #define SYSCLK_100 100000000 +/* I2C busses. */ +struct i2c_platform_data i2cplat = { + .bitrate = 400000, +}; + static int devices_init(void) { add_cfi_flash_device(DEVICE_ID_DYNAMIC, CFG_FLASH_BASE, 16 << 20, 0); + add_generic_device("i2c-fsl", 0, NULL, I2C1_BASE_ADDR, + 0x100, IORESOURCE_MEM, &i2cplat); + add_generic_device("i2c-fsl", 1, NULL, I2C2_BASE_ADDR, + 0x100, IORESOURCE_MEM, &i2cplat); + devfs_add_partition("nor0", 0xf80000, 0x80000, DEVFS_PARTITION_FIXED, "self0"); return 0; diff --git a/arch/ppc/configs/p2020rdb_defconfig b/arch/ppc/configs/p2020rdb_defconfig index f8a0687251..c040635e70 100644 --- a/arch/ppc/configs/p2020rdb_defconfig +++ b/arch/ppc/configs/p2020rdb_defconfig @@ -21,3 +21,6 @@ CONFIG_MALLOC_SIZE=0x200000 CONFIG_BAUDRATE=115200 CONFIG_DRIVER_SERIAL_NS16550=y CONFIG_RELOCATABLE=y +CONFIG_I2C=y +CONFIG_I2C_IMX=y +CONFIG_CMD_I2C=y diff --git a/arch/ppc/include/asm/fsl_i2c.h b/arch/ppc/include/asm/fsl_i2c.h deleted file mode 100644 index 4f71341327..0000000000 --- a/arch/ppc/include/asm/fsl_i2c.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Freescale I2C Controller - * - * Copyright 2006 Freescale Semiconductor, Inc. - * - * Based on earlier versions by Gleb Natapov <gnatapov@mrv.com>, - * Xianghua Xiao <x.xiao@motorola.com>, Eran Liberty (liberty@freescale.com), - * and Jeff Brown. - * Some bits are taken from linux driver writen by adrian@humboldt.co.uk. - * - * This software may be used and distributed according to the - * terms of the GNU Public License, Version 2, incorporated - * herein by reference. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef _ASM_FSL_I2C_H_ -#define _ASM_FSL_I2C_H_ - -#include <asm/types.h> - -typedef struct fsl_i2c { - - u8 adr; /* I2C slave address */ - u8 res0[3]; -#define I2C_ADR 0xFE -#define I2C_ADR_SHIFT 1 -#define I2C_ADR_RES ~(I2C_ADR) - - u8 fdr; /* I2C frequency divider register */ - u8 res1[3]; -#define IC2_FDR 0x3F -#define IC2_FDR_SHIFT 0 -#define IC2_FDR_RES ~(IC2_FDR) - - u8 cr; /* I2C control redister */ - u8 res2[3]; -#define I2C_CR_MEN 0x80 -#define I2C_CR_MIEN 0x40 -#define I2C_CR_MSTA 0x20 -#define I2C_CR_MTX 0x10 -#define I2C_CR_TXAK 0x08 -#define I2C_CR_RSTA 0x04 -#define I2C_CR_BCST 0x01 - - u8 sr; /* I2C status register */ - u8 res3[3]; -#define I2C_SR_MCF 0x80 -#define I2C_SR_MAAS 0x40 -#define I2C_SR_MBB 0x20 -#define I2C_SR_MAL 0x10 -#define I2C_SR_BCSTM 0x08 -#define I2C_SR_SRW 0x04 -#define I2C_SR_MIF 0x02 -#define I2C_SR_RXAK 0x01 - - u8 dr; /* I2C data register */ - u8 res4[3]; -#define I2C_DR 0xFF -#define I2C_DR_SHIFT 0 -#define I2C_DR_RES ~(I2C_DR) - - u8 dfsrr; /* I2C digital filter sampling rate register */ - u8 res5[3]; -#define I2C_DFSRR 0x3F -#define I2C_DFSRR_SHIFT 0 -#define I2C_DFSRR_RES ~(I2C_DR) - - /* Fill out the reserved block */ - u8 res6[0xE8]; -} fsl_i2c_t; - -#endif /* _ASM_I2C_H_ */ diff --git a/arch/ppc/mach-mpc85xx/include/mach/clocks.h b/arch/ppc/mach-mpc85xx/include/mach/clock.h index 2ab367b2ec..e20d68518e 100644 --- a/arch/ppc/mach-mpc85xx/include/mach/clocks.h +++ b/arch/ppc/mach-mpc85xx/include/mach/clock.h @@ -12,5 +12,6 @@ struct sys_info { unsigned long fsl_get_bus_freq(ulong dummy); unsigned long fsl_get_timebase_clock(void); +unsigned long fsl_get_i2c_freq(void); void fsl_get_sys_info(struct sys_info *sysInfo); #endif /* __ASM_ARCH_CLOCKS_H */ diff --git a/arch/ppc/mach-mpc85xx/include/mach/immap_85xx.h b/arch/ppc/mach-mpc85xx/include/mach/immap_85xx.h index b80224952d..b686a09b6a 100644 --- a/arch/ppc/mach-mpc85xx/include/mach/immap_85xx.h +++ b/arch/ppc/mach-mpc85xx/include/mach/immap_85xx.h @@ -129,4 +129,7 @@ #define MPC85xx_DEVDISR_TB1 0x00001000 #define MPC85xx_GUTS_RSTCR_OFFSET 0xb0 +#define I2C1_BASE_ADDR (CFG_IMMR + 0x3000) +#define I2C2_BASE_ADDR (CFG_IMMR + 0x3100) + #endif /*__IMMAP_85xx__*/ diff --git a/arch/ppc/mach-mpc85xx/speed.c b/arch/ppc/mach-mpc85xx/speed.c index 40d3664188..6778d57c29 100644 --- a/arch/ppc/mach-mpc85xx/speed.c +++ b/arch/ppc/mach-mpc85xx/speed.c @@ -30,7 +30,7 @@ #include <common.h> #include <asm/processor.h> -#include <mach/clocks.h> +#include <mach/clock.h> #include <mach/immap_85xx.h> #include <mach/mpc85xx.h> @@ -102,3 +102,12 @@ unsigned long fsl_get_timebase_clock(void) return (sysinfo.freqSystemBus + 4UL)/8UL; } + +unsigned long fsl_get_i2c_freq(void) +{ + struct sys_info sysinfo; + + fsl_get_sys_info(&sysinfo); + + return sysinfo.freqSystemBus / 2; +} diff --git a/arch/ppc/mach-mpc85xx/time.c b/arch/ppc/mach-mpc85xx/time.c index 408a28a2eb..c50591c961 100644 --- a/arch/ppc/mach-mpc85xx/time.c +++ b/arch/ppc/mach-mpc85xx/time.c @@ -25,7 +25,7 @@ #include <common.h> #include <clock.h> #include <init.h> -#include <mach/clocks.h> +#include <mach/clock.h> uint64_t ppc_clocksource_read(void) { |