~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-omap2/gpmc-smsc911x.c

Version: ~ [ linux-5.9-rc6 ] ~ [ linux-5.8.10 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.66 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.146 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.198 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.236 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.236 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * linux/arch/arm/mach-omap2/gpmc-smsc911x.c
  3  *
  4  * Copyright (C) 2009 Li-Pro.Net
  5  * Stephan Linz <linz@li-pro.net>
  6  *
  7  * Modified from linux/arch/arm/mach-omap2/gpmc-smc91x.c
  8  *
  9  * This program is free software; you can redistribute it and/or modify
 10  * it under the terms of the GNU General Public License version 2 as
 11  * published by the Free Software Foundation.
 12  */
 13 #define pr_fmt(fmt) "%s: " fmt, __func__
 14 
 15 #include <linux/kernel.h>
 16 #include <linux/platform_device.h>
 17 #include <linux/gpio.h>
 18 #include <linux/delay.h>
 19 #include <linux/interrupt.h>
 20 #include <linux/io.h>
 21 #include <linux/smsc911x.h>
 22 
 23 #include "gpmc.h"
 24 #include "gpmc-smsc911x.h"
 25 
 26 static struct resource gpmc_smsc911x_resources[] = {
 27         [0] = {
 28                 .flags          = IORESOURCE_MEM,
 29         },
 30         [1] = {
 31                 .flags          = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
 32         },
 33 };
 34 
 35 static struct smsc911x_platform_config gpmc_smsc911x_config = {
 36         .phy_interface  = PHY_INTERFACE_MODE_MII,
 37         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
 38         .irq_type       = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
 39 };
 40 
 41 /*
 42  * Initialize smsc911x device connected to the GPMC. Note that we
 43  * assume that pin multiplexing is done in the board-*.c file,
 44  * or in the bootloader.
 45  */
 46 void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *gpmc_cfg)
 47 {
 48         struct platform_device *pdev;
 49         unsigned long cs_mem_base;
 50         int ret;
 51 
 52         if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
 53                 pr_err("Failed to request GPMC mem region\n");
 54                 return;
 55         }
 56 
 57         gpmc_smsc911x_resources[0].start = cs_mem_base + 0x0;
 58         gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff;
 59 
 60         if (gpio_request_one(gpmc_cfg->gpio_irq, GPIOF_IN, "smsc911x irq")) {
 61                 pr_err("Failed to request IRQ GPIO%d\n", gpmc_cfg->gpio_irq);
 62                 goto free1;
 63         }
 64 
 65         gpmc_smsc911x_resources[1].start = gpio_to_irq(gpmc_cfg->gpio_irq);
 66 
 67         if (gpio_is_valid(gpmc_cfg->gpio_reset)) {
 68                 ret = gpio_request_one(gpmc_cfg->gpio_reset,
 69                                        GPIOF_OUT_INIT_HIGH, "smsc911x reset");
 70                 if (ret) {
 71                         pr_err("Failed to request reset GPIO%d\n",
 72                                gpmc_cfg->gpio_reset);
 73                         goto free2;
 74                 }
 75 
 76                 gpio_set_value(gpmc_cfg->gpio_reset, 0);
 77                 msleep(100);
 78                 gpio_set_value(gpmc_cfg->gpio_reset, 1);
 79         }
 80 
 81         gpmc_smsc911x_config.flags = gpmc_cfg->flags ? : SMSC911X_USE_16BIT;
 82 
 83         pdev = platform_device_register_resndata(NULL, "smsc911x", gpmc_cfg->id,
 84                  gpmc_smsc911x_resources, ARRAY_SIZE(gpmc_smsc911x_resources),
 85                  &gpmc_smsc911x_config, sizeof(gpmc_smsc911x_config));
 86         if (IS_ERR(pdev)) {
 87                 pr_err("Unable to register platform device\n");
 88                 gpio_free(gpmc_cfg->gpio_reset);
 89                 goto free2;
 90         }
 91 
 92         return;
 93 
 94 free2:
 95         gpio_free(gpmc_cfg->gpio_irq);
 96 free1:
 97         gpmc_cs_free(gpmc_cfg->cs);
 98 
 99         pr_err("Could not initialize smsc911x device\n");
100 }
101 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp