From patchwork Tue Jun 12 16:37:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vikram Narayanan X-Patchwork-Id: 164447 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 E5EAFB6FBA for ; Wed, 13 Jun 2012 02:38:07 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D15B128095; Tue, 12 Jun 2012 18:38:04 +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 EAY2-sWpXCdE; Tue, 12 Jun 2012 18:38:04 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 972162808C; Tue, 12 Jun 2012 18:38:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6A4792808C for ; Tue, 12 Jun 2012 18:38:00 +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 a9WvlWVHjBGN for ; Tue, 12 Jun 2012 18:37: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 mail-pz0-f44.google.com (mail-pz0-f44.google.com [209.85.210.44]) by theia.denx.de (Postfix) with ESMTPS id 0C5592808B for ; Tue, 12 Jun 2012 18:37:57 +0200 (CEST) Received: by dacx6 with SMTP id x6so6563650dac.3 for ; Tue, 12 Jun 2012 09:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=LQYmtF0FGoSqlF0hJUAUbwGeksr8+YgucqIrO/d5vgc=; b=F5H7MH14v0lab6BFqeI8I/JwQAphPmRHdgd9V/qsngC8/6pYzJ/te28zwvsGJLQLuJ 081DIo90+vqKiY+agEuZsnMR7i4M8Gw57jaseVKrhiUmry9lHKPQV1MVoo4k7IlIV4cv HL4OvaVNxXzoBNV9Dh1liSECKFmXgur+XYw51LG2SDyF2JYhikfRpuQNgTgGqQm2jbH2 Ek/0qdLZISU2VW8IBMyuI0v2hxvhZBTdxc7Lr/2MuI/shvMowS2XqXePE5fzLqRa6yDE 5Evi9IHwrxzbYwhiSJfjHslkLjdLdBLpNLyGmlz7ZjzJMJK1wC4LH6JPdcfEFb1vqVjs Z3HA== Received: by 10.68.231.8 with SMTP id tc8mr37736014pbc.140.1339519074193; Tue, 12 Jun 2012 09:37:54 -0700 (PDT) Received: from [101.63.178.247] ([101.63.178.247]) by mx.google.com with ESMTPS id rv5sm2512492pbc.56.2012.06.12.09.37.49 (version=SSLv3 cipher=OTHER); Tue, 12 Jun 2012 09:37:53 -0700 (PDT) Message-ID: <4FD77055.3080502@gmail.com> Date: Tue, 12 Jun 2012 22:07:41 +0530 From: Vikram Narayanan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: u-boot@lists.denx.de Cc: Fabio Estevam , John Rigby Subject: [U-Boot] [PATCH v2] tx25: Use generic gpio_* calls 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Changes from v1: Used appropriate gpio_* lib calls. Acked-by: Stefano Babic --- Instead of manipulating gpio registers directly, use the calls from the gpio library. Signed-off-by: Vikram Narayanan Cc: Fabio Estevam Cc: John Rigby Cc: Stefano Babic --- board/karo/tx25/tx25.c | 25 +++++++++---------------- 1 files changed, 9 insertions(+), 16 deletions(-) diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c index 2a29943..ff2de38 100644 --- a/board/karo/tx25/tx25.c +++ b/board/karo/tx25/tx25.c @@ -34,14 +34,13 @@ DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_FEC_MXC +#define GPIO_FEC_RESET_B MXC_GPIO_PORT_TO_NUM(4, 7) +#define GPIO_FEC_ENABLE_B MXC_GPIO_PORT_TO_NUM(4, 9) void tx25_fec_init(void) { struct iomuxc_mux_ctl *muxctl; struct iomuxc_pad_ctl *padctl; - u32 val; u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5); - struct gpio_regs *gpio4 = (struct gpio_regs *)IMX_GPIO4_BASE; - struct gpio_regs *gpio3 = (struct gpio_regs *)IMX_GPIO3_BASE; u32 saved_rdata0_mode, saved_rdata1_mode, saved_rx_dv_mode; debug("tx25_fec_init\n"); @@ -66,18 +65,15 @@ void tx25_fec_init(void) writel(0x0, &padctl->pad_d11); /* drop PHY power and assert reset (low) */ - val = readl(&gpio4->gpio_dr) & ~((1 << 7) | (1 << 9)); - writel(val, &gpio4->gpio_dr); - val = readl(&gpio4->gpio_dir) | (1 << 7) | (1 << 9); - writel(val, &gpio4->gpio_dir); + gpio_direction_output(GPIO_FEC_RESET_B, 0); + gpio_direction_output(GPIO_FEC_ENABLE_B, 0); mdelay(5); debug("resetting phy\n"); /* turn on PHY power leaving reset asserted */ - val = readl(&gpio4->gpio_dr) | 1 << 9; - writel(val, &gpio4->gpio_dr); + gpio_direction_output(GPIO_FEC_ENABLE_B, 1); mdelay(10); @@ -107,19 +103,16 @@ void tx25_fec_init(void) /* * set each to 1 and make each an output */ - val = readl(&gpio3->gpio_dr) | (1 << 10) | (1 << 11) | (1 << 12); - writel(val, &gpio3->gpio_dr); - val = readl(&gpio3->gpio_dir) | (1 << 10) | (1 << 11) | (1 << 12); - writel(val, &gpio3->gpio_dir); + gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 10), 1); + gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 11), 1); + gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 12), 1); mdelay(22); /* this value came from RedBoot */ /* * deassert PHY reset */ - val = readl(&gpio4->gpio_dr) | 1 << 7; - writel(val, &gpio4->gpio_dr); - writel(val, &gpio4->gpio_dr); + gpio_set_value(GPIO_FEC_RESET_B, 1); mdelay(5);