From patchwork Thu Sep 20 11:50:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Wilczek X-Patchwork-Id: 185382 X-Patchwork-Delegate: promsoft@gmail.com 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 2D4692C009D for ; Thu, 20 Sep 2012 21:51:18 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EC852281C7; Thu, 20 Sep 2012 13:51:15 +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 8LLUGZornirH; Thu, 20 Sep 2012 13:51:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 689CF281AC; Thu, 20 Sep 2012 13:51:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A4929281A2 for ; Thu, 20 Sep 2012 13:51:08 +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 TMY1oWFU27Ip for ; Thu, 20 Sep 2012 13:51:07 +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 mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by theia.denx.de (Postfix) with ESMTP id EB2A0281AC for ; Thu, 20 Sep 2012 13:50:57 +0200 (CEST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAN00H9CCWOHYV0@mailout3.samsung.com> for u-boot@lists.denx.de; Thu, 20 Sep 2012 20:50:53 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-36-505b031debac Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 81.E6.03783.D130B505; Thu, 20 Sep 2012 20:50:53 +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 <0MAN00990CWFLS90@mmp2.samsung.com> for u-boot@lists.denx.de; Thu, 20 Sep 2012 20:50:53 +0900 (KST) From: Piotr Wilczek To: u-boot@lists.denx.de Date: Thu, 20 Sep 2012 13:50:34 +0200 Message-id: <1348141834-3603-2-git-send-email-p.wilczek@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1348141834-3603-1-git-send-email-p.wilczek@samsung.com> References: <1346228122-13444-2-git-send-email-p.wilczek@samsung.com> <1348141834-3603-1-git-send-email-p.wilczek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCJMWRmVeSWpSXmKPExsVy+t9jQV1Z5ugAg1PLZC3e7u1kd2D0OHtn B2MAYxSXTUpqTmZZapG+XQJXxr/nX5gL+uUqvj1+xdrA+FKyi5GTQ0LAROLrxyfMELaYxIV7 69m6GLk4hASmM0q0tl1lgnAWM0msn7UOrIpNQFti+Zs3jCC2iICExK/+q4wgRcwC/xglHu+5 AlTEwSEs4CZx55wYSA2LgKrEt2lnwep5BVwkPp+9yQaxTV7i6f0+MJtTwFWi++5HqM0NjBI7 DxxknMDIu4CRYRWjaGpBckFxUnquoV5xYm5xaV66XnJ+7iZGsN+fSe1gXNlgcYhRgINRiYe3 cXlUgBBrYllxZe4hRgkOZiUR3o0TgUK8KYmVValF+fFFpTmpxYcYpTlYlMR5hT8FBggJpCeW pGanphakFsFkmTg4pRoYW74WqjgoCflUrM+23nWJyWV+bv7zPLVdm/Z1avR27TBQcOGflB67 ZcLkE8aCLGtjHugv/3rCqkIxMDL7oyP/Rb6b680XJDREa5a7nHIP5vh1z9mA4bIlf5izWJNi c5NXgMGzKKdrdrsO/nnTVG2sVCm9VPnY0nrnU/y7e7y/9Vkxq8bxzFFiKc5INNRiLipOBACG H2Ld9wEAAA== Cc: Piotr Wilczek , Kyungmin Park Subject: [U-Boot] [PATCH v2] arm:exynos4:universal_c210: implement software SPI 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 This patch implements software SPI for the universal C210 board. Signed-off-by: Piotr Wilczek Signed-off-by: Kyungmin Park CC: Minkyu Kang CC: Wolfgang Denk CC: Jean-Christophe PLAGNIOL-VILLARD --- Changes in v2: - removed space between # and include; - changed return in spi_cs_is_valid function; board/samsung/universal_c210/universal.c | 35 ++++++++++++++++++++++++++++++ drivers/spi/soft_spi.c | 7 +++++- include/configs/s5pc210_universal.h | 19 ++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletions(-) diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c index ded97ca..6947e83 100644 --- a/board/samsung/universal_c210/universal.c +++ b/board/samsung/universal_c210/universal.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -33,6 +34,9 @@ #include #include #include +#if defined(CONFIG_SOFT_SPI) +# include +#endif DECLARE_GLOBAL_DATA_PTR; @@ -284,3 +288,34 @@ int board_early_init_f(void) return 0; } + +void soft_spi_init() +{ + gpio_direction_output(CONFIG_SOFT_SPI_GPIO_SCLK, + CONFIG_SOFT_SPI_MODE & SPI_CPOL); + gpio_direction_output(CONFIG_SOFT_SPI_GPIO_MOSI, 1); + gpio_direction_input(CONFIG_SOFT_SPI_GPIO_MISO); + gpio_direction_output(CONFIG_SOFT_SPI_GPIO_CS, + !(CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH)); +} + +void spi_cs_activate(struct spi_slave *slave) +{ + gpio_set_value(CONFIG_SOFT_SPI_GPIO_CS, + !(CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH)); + SPI_SCL(1); + gpio_set_value(CONFIG_SOFT_SPI_GPIO_CS, + CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH); +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + gpio_set_value(CONFIG_SOFT_SPI_GPIO_CS, + !(CONFIG_SOFT_SPI_MODE & SPI_CS_HIGH)); +} + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && cs == 0; +} + diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c index 13df8cb..a0a3012 100644 --- a/drivers/spi/soft_spi.c +++ b/drivers/spi/soft_spi.c @@ -29,6 +29,10 @@ #include +#if defined(CONFIG_SOFT_SPI) +# include +#endif + /*----------------------------------------------------------------------- * Definitions */ @@ -59,8 +63,9 @@ static inline struct soft_spi_slave *to_soft_spi(struct spi_slave *slave) void spi_init (void) { #ifdef SPI_INIT +#ifdef CONFIG_SYS_IMMR volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; - +#endif SPI_INIT; #endif } diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h index 46f2663..f7a7443 100644 --- a/include/configs/s5pc210_universal.h +++ b/include/configs/s5pc210_universal.h @@ -264,4 +264,23 @@ #define CONFIG_USB_GADGET_S3C_UDC_OTG #define CONFIG_USB_GADGET_DUALSPEED +/* + * SPI Settings + */ +#define CONFIG_SOFT_SPI +#define CONFIG_SOFT_SPI_MODE SPI_MODE_3 +#define CONFIG_SOFT_SPI_GPIO_SCLK exynos4_gpio_part2_get_nr(y3, 1) +#define CONFIG_SOFT_SPI_GPIO_MOSI exynos4_gpio_part2_get_nr(y3, 3) +#define CONFIG_SOFT_SPI_GPIO_MISO exynos4_gpio_part2_get_nr(y3, 0) +#define CONFIG_SOFT_SPI_GPIO_CS exynos4_gpio_part2_get_nr(y4, 3) + +#define SPI_DELAY udelay(1) +#define SPI_INIT soft_spi_init() +#define SPI_SCL(bit) gpio_set_value(CONFIG_SOFT_SPI_GPIO_SCLK, bit) +#define SPI_SDA(bit) gpio_set_value(CONFIG_SOFT_SPI_GPIO_MOSI, bit) +#define SPI_READ gpio_get_value(CONFIG_SOFT_SPI_GPIO_MISO) +#ifndef __ASSEMBLY__ +void soft_spi_init(void); +#endif + #endif /* __CONFIG_H */