From patchwork Wed Sep 5 09:15:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 181789 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 290692C008D for ; Wed, 5 Sep 2012 19:16:17 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 348EE281B8; Wed, 5 Sep 2012 11:16:11 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ALGSrmO8M5X4; Wed, 5 Sep 2012 11:16:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A8A47281A0; Wed, 5 Sep 2012 11:16:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5731B2818F for ; Wed, 5 Sep 2012 11:16:01 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FcX7o9ovJMSY for ; Wed, 5 Sep 2012 11:15:59 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by theia.denx.de (Postfix) with ESMTP id BF8282818D for ; Wed, 5 Sep 2012 11:15:58 +0200 (CEST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9V00IU5DPSZZ60@mailout2.samsung.com> for u-boot@lists.denx.de; Wed, 05 Sep 2012 18:15:33 +0900 (KST) X-AuditID: cbfee61a-b7fd26d000002b62-95-50471835195c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D6.57.11106.53817405; Wed, 05 Sep 2012 18:15:33 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M9V00IC2DPOXAH1@mmp1.samsung.com> for u-boot@lists.denx.de; Wed, 05 Sep 2012 18:15:33 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Wed, 05 Sep 2012 11:15:20 +0200 Message-id: <1346836521-15269-2-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1346836521-15269-1-git-send-email-l.majewski@samsung.com> References: <1346142797-17645-1-git-send-email-l.majewski@samsung.com> <1346836521-15269-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKJMWRmVeSWpSXmKPExsVy+t9jAV1TCfcAg5NzLCze7u1kd2D0OHtn B2MAYxSXTUpqTmZZapG+XQJXxttfJ1kL3mhVvNv6l7WB8Y9SFyMnh4SAicTFxz+YIWwxiQv3 1rN1MXJxCAksYpR48vQ9E4SzmEli/8TTjCBVbAJ6Ep/vPmUCsUUEJCR+9V9lBCliFtjHKLFl 6h42kISwQLzEqvsPWEBsFgFViTt7z4I18Aq4SSzeuowJYp28xNP7fWD1nALuEgvOvGKG2NbM KLGjYQ7bBEbeBYwMqxhFUwuSC4qT0nMN9YoTc4tL89L1kvNzNzGCPf9MagfjygaLQ4wCHIxK PLwM3m4BQqyJZcWVuYcYJTiYlUR4b692DRDiTUmsrEotyo8vKs1JLT7EKM3BoiTO63TOLkBI ID2xJDU7NbUgtQgmy8TBKdXAqNVvuzD/96bb6QbdRpsWxh3ZlN40N//iBEFFl4u7NrJbXde4 Xn8ylPsTj+reeIHID4tDjLzvakr6Rt063/ek6t4uCwHXYqGnWQtuHUoXcBW30Z3ZtFv08s8J 6/aK3ejLFmXgWcdpvlIqSvpw3Z2dtkJ6GRp/Mo79cOw/klq6ValWgI/9/b4lSizFGYmGWsxF xYkAZst4PvgBAAA= Cc: Kyungmin Park , Heiko Schocher Subject: [U-Boot] [PATCH v4 1/2] i2c:soft:multi: Support for multiple soft I2C buses at Samsung boards X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Support for multiple soft I2C buses. Multibus I2C support is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses. Common definition of I2C_X I2C buses is provided at . TEST HW: Samsung's Exynos4210 evt.0.1 - Trats development board Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Cc: Heiko Schocher Cc: Minkyu Kang Acked-by: Heiko Schocher --- Changes for v2: - Common Samsung code has been put to board/samsung/common/multi_i2c.c file - I2C_{4|5} have been renamed to I2C_{0|1} - *soft_i2c_name[] table has been removed Changes for v3: - None Changes for v4: - Common definitions of available I2C buses are now defined at - Compatibility layer (I2C_0) has been added temporarily to not break the Trats I2C communication with PMIC. It will be removed when redesigned PMIC will be posted --- board/samsung/common/Makefile | 43 +++++++++++++++++++++++++ board/samsung/common/multi_i2c.c | 65 ++++++++++++++++++++++++++++++++++++++ include/i2c.h | 12 +++++++ 3 files changed, 120 insertions(+), 0 deletions(-) create mode 100644 board/samsung/common/Makefile create mode 100644 board/samsung/common/multi_i2c.c diff --git a/board/samsung/common/Makefile b/board/samsung/common/Makefile new file mode 100644 index 0000000..0bcd594 --- /dev/null +++ b/board/samsung/common/Makefile @@ -0,0 +1,43 @@ +# +# Copyright (C) 2012 Samsung Electronics +# Lukasz Majewski +# +# 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 as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# 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 +# + +include $(TOPDIR)/config.mk + +LIB = $(obj)libsamsung.o + +COBJS-$(CONFIG_SOFT_I2C_MULTI_BUS) += multi_i2c.o + +SRCS := $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS-y)) + +$(LIB): $(obj).depend $(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +######################################################################### diff --git a/board/samsung/common/multi_i2c.c b/board/samsung/common/multi_i2c.c new file mode 100644 index 0000000..d6c3d37 --- /dev/null +++ b/board/samsung/common/multi_i2c.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * Lukasz Majewski + * + * 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 as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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 + */ + +#include +#include + +/* Handle multiple I2C buses instances */ +int get_multi_scl_pin(void) +{ + unsigned int bus = I2C_GET_BUS(); + + switch (bus) { + case I2C_0: /* I2C_0 definition - compatibility layer */ + case I2C_5: + return CONFIG_SOFT_I2C_I2C5_SCL; + case I2C_9: + return CONFIG_SOFT_I2C_I2C9_SCL; + default: + printf("I2C_%d not supported!\n", bus); + }; + + return 0; +} + +int get_multi_sda_pin(void) +{ + unsigned int bus = I2C_GET_BUS(); + + switch (bus) { + case I2C_0: /* I2C_0 definition - compatibility layer */ + case I2C_5: + return CONFIG_SOFT_I2C_I2C5_SDA; + case I2C_9: + return CONFIG_SOFT_I2C_I2C9_SDA; + default: + printf("I2C_%d not supported!\n", bus); + }; + + return 0; +} + +int multi_i2c_init(void) +{ + return 0; +} diff --git a/include/i2c.h b/include/i2c.h index 1f35acf..16f099d 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -250,4 +250,16 @@ static inline void I2C_SET_BUS(unsigned int bus) i2c_set_bus_num(bus); } +/* Multi I2C definitions */ +enum { + I2C_0, I2C_1, I2C_2, I2C_3, I2C_4, I2C_5, I2C_6, I2C_7, + I2C_8, I2C_9, I2C_10, +}; + +/* Multi I2C busses handling */ +#ifdef CONFIG_SOFT_I2C_MULTI_BUS +extern int get_multi_scl_pin(void); +extern int get_multi_sda_pin(void); +extern int multi_i2c_init(void); +#endif #endif /* _I2C_H_ */