From patchwork Mon Sep 24 11:56:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Wilczek X-Patchwork-Id: 186385 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 A12EF2C007B for ; Mon, 24 Sep 2012 21:57:11 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EFBE82809F; Mon, 24 Sep 2012 13:57:09 +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 ldBG59H4HSwB; Mon, 24 Sep 2012 13:57:09 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C69B4280A0; Mon, 24 Sep 2012 13:57:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B7F3528084 for ; Mon, 24 Sep 2012 13:56:57 +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 EACd7nSz8lW1 for ; Mon, 24 Sep 2012 13:56:57 +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 EA54028088 for ; Mon, 24 Sep 2012 13:56:56 +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 <0MAU00HCCRTVHB41@mailout2.samsung.com> for u-boot@lists.denx.de; Mon, 24 Sep 2012 20:56:56 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-bb-50604a88189b Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 28.8E.03783.88A40605; Mon, 24 Sep 2012 20:56:56 +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 <0MAU00I5QRUFYR60@mmp1.samsung.com> for u-boot@lists.denx.de; Mon, 24 Sep 2012 20:56:56 +0900 (KST) From: Piotr Wilczek To: u-boot@lists.denx.de Date: Mon, 24 Sep 2012 13:56:31 +0200 Message-id: <1348487791-18435-3-git-send-email-p.wilczek@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1348487791-18435-1-git-send-email-p.wilczek@samsung.com> References: <1348141834-3603-2-git-send-email-p.wilczek@samsung.com> <1348487791-18435-1-git-send-email-p.wilczek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCJMWRmVeSWpSXmKPExsVy+t9jAd0Or4QAg3Mn+Cze7u1kd2D0OHtn B2MAYxSXTUpqTmZZapG+XQJXRkPza6aCBeIVp+7uYmtgnCLSxcjJISFgItG07gEjhC0mceHe erYuRi4OIYFFjBJXV61hgXAWM0l8vHKUBaSKTUBbYvmbN2AdIgISEr/6rzKCFDEL/GOUeLzn CnMXIweHsICjxMHjviA1LAKqEi3nrrOC2LwCrhLvtnWwQ2yTl3h6v48NxOYUcJO4df8EK8Sy BkaJa939LBMYeRcwMqxiFE0tSC4oTkrPNdQrTswtLs1L10vOz93ECPb7M6kdjCsbLA4xCnAw KvHwcp6PDxBiTSwrrsw9xCjBwawkwjvRMCFAiDclsbIqtSg/vqg0J7X4EKM0B4uSOK/wp8AA IYH0xJLU7NTUgtQimCwTB6dUA2P574Pa+h8PruSoOTorimlto8Zm4726cn8qDRwML1YctFpt JOgf27ah/Ziyo9g3P2P/lXvXMXX7Sbzy3qzVHBn+8F3Ws75La3SNG25sj5n3ouqczOU/d9Pv PTt5MnZ/wXGp/07+vW4T/FqCnCrvfzhWaj5RavuzP59Ermx2sHNb4b+Hu8jEz0SJpTgj0VCL uag4EQAEzcce9wEAAA== Cc: Piotr Wilczek , Kyungmin Park Subject: [U-Boot] [PATCH v3 2/2] exynos4: universal_C210: use 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 use software spi on Samsung Universal C210 board. Signed-off-by: Piotr Wilczek Signed-off-by: Kyungmin Park CC: Minkyu Kang --- Changes in v2: - removed space between # and include; - changed return in spi_cs_is_valid function; Changes in v3: - New patch from splited v2: board/samsung/universal_c210/universal.c | 34 ++++++++++++++++++++++++++++++ include/configs/s5pc210_universal.h | 19 ++++++++++++++++ 2 files changed, 53 insertions(+), 0 deletions(-) diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c index ded97ca..72999d9 100644 --- a/board/samsung/universal_c210/universal.c +++ b/board/samsung/universal_c210/universal.c @@ -23,7 +23,9 @@ */ #include +#include #include +#include #include #include #include @@ -284,3 +286,35 @@ int board_early_init_f(void) return 0; } + +#ifdef CONFIG_SOFT_SPI +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; +} +#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 */