18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2009-2011 Florian Fainelli <florian@openwrt.org> 78c2ecf20Sopenharmony_ci * Copyright (C) 2010 Tanguy Bouzeloc <tanguy.bouzeloc@efixo.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/init.h> 118c2ecf20Sopenharmony_ci#include <linux/kernel.h> 128c2ecf20Sopenharmony_ci#include <linux/export.h> 138c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 148c2ecf20Sopenharmony_ci#include <linux/err.h> 158c2ecf20Sopenharmony_ci#include <linux/clk.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <bcm63xx_cpu.h> 188c2ecf20Sopenharmony_ci#include <bcm63xx_dev_spi.h> 198c2ecf20Sopenharmony_ci#include <bcm63xx_regs.h> 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic struct resource spi_resources[] = { 228c2ecf20Sopenharmony_ci { 238c2ecf20Sopenharmony_ci .start = -1, /* filled at runtime */ 248c2ecf20Sopenharmony_ci .end = -1, /* filled at runtime */ 258c2ecf20Sopenharmony_ci .flags = IORESOURCE_MEM, 268c2ecf20Sopenharmony_ci }, 278c2ecf20Sopenharmony_ci { 288c2ecf20Sopenharmony_ci .start = -1, /* filled at runtime */ 298c2ecf20Sopenharmony_ci .flags = IORESOURCE_IRQ, 308c2ecf20Sopenharmony_ci }, 318c2ecf20Sopenharmony_ci}; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistatic struct platform_device bcm63xx_spi_device = { 348c2ecf20Sopenharmony_ci .id = -1, 358c2ecf20Sopenharmony_ci .num_resources = ARRAY_SIZE(spi_resources), 368c2ecf20Sopenharmony_ci .resource = spi_resources, 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciint __init bcm63xx_spi_register(void) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci if (BCMCPU_IS_6328() || BCMCPU_IS_6345()) 428c2ecf20Sopenharmony_ci return -ENODEV; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci spi_resources[0].start = bcm63xx_regset_address(RSET_SPI); 458c2ecf20Sopenharmony_ci spi_resources[0].end = spi_resources[0].start; 468c2ecf20Sopenharmony_ci spi_resources[1].start = bcm63xx_get_irq_number(IRQ_SPI); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci if (BCMCPU_IS_6338() || BCMCPU_IS_6348()) { 498c2ecf20Sopenharmony_ci bcm63xx_spi_device.name = "bcm6348-spi", 508c2ecf20Sopenharmony_ci spi_resources[0].end += BCM_6348_RSET_SPI_SIZE - 1; 518c2ecf20Sopenharmony_ci } 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci if (BCMCPU_IS_3368() || BCMCPU_IS_6358() || BCMCPU_IS_6362() || 548c2ecf20Sopenharmony_ci BCMCPU_IS_6368()) { 558c2ecf20Sopenharmony_ci bcm63xx_spi_device.name = "bcm6358-spi", 568c2ecf20Sopenharmony_ci spi_resources[0].end += BCM_6358_RSET_SPI_SIZE - 1; 578c2ecf20Sopenharmony_ci } 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci return platform_device_register(&bcm63xx_spi_device); 608c2ecf20Sopenharmony_ci} 61