From patchwork Mon Sep 3 15:58:21 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: 181380 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 3F6DB2C0093 for ; Tue, 4 Sep 2012 01:59:08 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 348F5280C5; Mon, 3 Sep 2012 17:59: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 8Vphr9bOBWVf; Mon, 3 Sep 2012 17:59:00 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C672A28098; Mon, 3 Sep 2012 17:58:53 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E0CB22808F for ; Mon, 3 Sep 2012 17:58:48 +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 bTqt9+Gh3wb6 for ; Mon, 3 Sep 2012 17:58:45 +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 mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by theia.denx.de (Postfix) with ESMTP id 88EA92808B for ; Mon, 3 Sep 2012 17:58:44 +0200 (CEST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9S00G1771RZCW0@mailout1.samsung.com> for u-boot@lists.denx.de; Tue, 04 Sep 2012 00:58:41 +0900 (KST) X-AuditID: cbfee61a-b7fd26d000002b62-2e-5044d3b1e372 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id FE.DB.11106.1B3D4405; Tue, 04 Sep 2012 00:58:41 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M9S00A3R71DJ990@mmp2.samsung.com> for u-boot@lists.denx.de; Tue, 04 Sep 2012 00:58:41 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Mon, 03 Sep 2012 17:58:21 +0200 Message-id: <1346687902-5979-2-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1346687902-5979-1-git-send-email-l.majewski@samsung.com> References: <1346142797-17645-1-git-send-email-l.majewski@samsung.com> <1346687902-5979-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jQd2Nl10CDFYcN7d4u7eT3YHR4+yd HYwBjFFcNimpOZllqUX6dglcGZMe/2MpeKJasXBbG3MD40e5LkZODgkBE4lfz2+wQNhiEhfu rWfrYuTiEBKYzigx49AiKGcxk8ThAxeZQKrYBPQkPt99CmaLCEhI/Oq/yghSxCywj1Fiy9Q9 bCAJYYF4iX0r/gIVcXCwCKhK/J6UBWLyCrhKbH2mCrFMXuLp/T6wak4BN4kJ3zcxQuxqYpTo uzqHeQIj7wJGhlWMoqkFyQXFSem5hnrFibnFpXnpesn5uZsYwV5/JrWDcWWDxSFGAQ5GJR7e wHfOAUKsiWXFlbmHGCU4mJVEeL8sdgkQ4k1JrKxKLcqPLyrNSS0+xCjNwaIkzut0zi5ASCA9 sSQ1OzW1ILUIJsvEwSnVwOj/JPBikvShIwvDDHuVF581Xh0bOaNr0sKwsuJ3ar/3rAg5d3JO 16LGO255u42MPjlbr1sm5KUsvbNmgriBTHPiKT7WRTV6yotjbT2/ZF0WL5eY63o6+EbtUznr 4JSH/znXN0YZ8/3bsG13+t4nLx0iP7e+f2b6+WDXxaUTnK9rc7xutP1g7KDEUpyRaKjFXFSc CAArNo3P9gEAAA== Cc: Kyungmin Park , Heiko Schocher Subject: [U-Boot] [PATCH v3 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. The goal is achieved by defining get_multi_{sda|scl}_pin functions to switch between multiple "soft" I2C buses. Common definition of I2C_{0|1} 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 --- 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 --- board/samsung/common/Makefile | 43 +++++++++++++++++++++++++++++ board/samsung/common/multi_i2c.c | 55 ++++++++++++++++++++++++++++++++++++++ include/i2c.h | 11 +++++++ 3 files changed, 109 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..d8d59fb --- /dev/null +++ b/board/samsung/common/multi_i2c.c @@ -0,0 +1,55 @@ +/* + * 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) +{ + switch (I2C_GET_BUS()) { + case I2C_0: + return CONFIG_SOFT_I2C_I2C0_SCL; + case I2C_1: + return CONFIG_SOFT_I2C_I2C1_SCL; + }; + + return 0; +} + +int get_multi_sda_pin(void) +{ + switch (I2C_GET_BUS()) { + case I2C_0: + return CONFIG_SOFT_I2C_I2C0_SDA; + case I2C_1: + return CONFIG_SOFT_I2C_I2C1_SDA; + }; + + return 0; +} + +int multi_i2c_init(void) +{ + return 0; +} diff --git a/include/i2c.h b/include/i2c.h index 1f35acf..00a3933 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -250,4 +250,15 @@ static inline void I2C_SET_BUS(unsigned int bus) i2c_set_bus_num(bus); } +/* Multi I2C busses handling */ +#ifdef CONFIG_SOFT_I2C_MULTI_BUS +enum { + I2C_0, + I2C_1, +}; + +extern int get_multi_scl_pin(void); +extern int get_multi_sda_pin(void); +extern int multi_i2c_init(void); +#endif #endif /* _I2C_H_ */