| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * SuperH HSPI bus driver | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2011  Kuninori Morimoto | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Based on spi-sh.c: | 
					
						
							|  |  |  |  * Based on pxa2xx_spi.c: | 
					
						
							|  |  |  |  * Copyright (C) 2011 Renesas Solutions Corp. | 
					
						
							|  |  |  |  * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation; version 2 of the License. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <linux/clk.h>
 | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | #include <linux/module.h>
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/timer.h>
 | 
					
						
							|  |  |  | #include <linux/delay.h>
 | 
					
						
							|  |  |  | #include <linux/list.h>
 | 
					
						
							|  |  |  | #include <linux/interrupt.h>
 | 
					
						
							|  |  |  | #include <linux/platform_device.h>
 | 
					
						
							|  |  |  | #include <linux/pm_runtime.h>
 | 
					
						
							|  |  |  | #include <linux/io.h>
 | 
					
						
							|  |  |  | #include <linux/spi/spi.h>
 | 
					
						
							|  |  |  | #include <linux/spi/sh_hspi.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define SPCR	0x00
 | 
					
						
							|  |  |  | #define SPSR	0x04
 | 
					
						
							|  |  |  | #define SPSCR	0x08
 | 
					
						
							|  |  |  | #define SPTBR	0x0C
 | 
					
						
							|  |  |  | #define SPRBR	0x10
 | 
					
						
							|  |  |  | #define SPCR2	0x14
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* SPSR */ | 
					
						
							|  |  |  | #define RXFL	(1 << 2)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct hspi_priv { | 
					
						
							|  |  |  | 	void __iomem *addr; | 
					
						
							|  |  |  | 	struct spi_master *master; | 
					
						
							|  |  |  | 	struct device *dev; | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 	struct clk *clk; | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  *		basic function | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void hspi_write(struct hspi_priv *hspi, int reg, u32 val) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	iowrite32(val, hspi->addr + reg); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static u32 hspi_read(struct hspi_priv *hspi, int reg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ioread32(hspi->addr + reg); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | static void hspi_bit_set(struct hspi_priv *hspi, int reg, u32 mask, u32 set) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	u32 val = hspi_read(hspi, reg); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	val &= ~mask; | 
					
						
							|  |  |  | 	val |= set & mask; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	hspi_write(hspi, reg, val); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *		transfer function | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static int hspi_status_check_timeout(struct hspi_priv *hspi, u32 mask, u32 val) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int t = 256; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while (t--) { | 
					
						
							|  |  |  | 		if ((mask & hspi_read(hspi, SPSR)) == val) | 
					
						
							|  |  |  | 			return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-26 17:59:20 -07:00
										 |  |  | 		udelay(10); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dev_err(hspi->dev, "timeout\n"); | 
					
						
							|  |  |  | 	return -ETIMEDOUT; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *		spi master function | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | #define hspi_hw_cs_enable(hspi)		hspi_hw_cs_ctrl(hspi, 0)
 | 
					
						
							|  |  |  | #define hspi_hw_cs_disable(hspi)	hspi_hw_cs_ctrl(hspi, 1)
 | 
					
						
							|  |  |  | static void hspi_hw_cs_ctrl(struct hspi_priv *hspi, int hi) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	hspi_bit_set(hspi, SPSCR, (1 << 6), (hi) << 6); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | static void hspi_hw_setup(struct hspi_priv *hspi, | 
					
						
							|  |  |  | 			  struct spi_message *msg, | 
					
						
							|  |  |  | 			  struct spi_transfer *t) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct spi_device *spi = msg->spi; | 
					
						
							|  |  |  | 	struct device *dev = hspi->dev; | 
					
						
							|  |  |  | 	u32 spcr, idiv_clk; | 
					
						
							|  |  |  | 	u32 rate, best_rate, min, tmp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * find best IDIV/CLKCx settings | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	min = ~0; | 
					
						
							|  |  |  | 	best_rate = 0; | 
					
						
							|  |  |  | 	spcr = 0; | 
					
						
							|  |  |  | 	for (idiv_clk = 0x00; idiv_clk <= 0x3F; idiv_clk++) { | 
					
						
							|  |  |  | 		rate = clk_get_rate(hspi->clk); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* IDIV calculation */ | 
					
						
							|  |  |  | 		if (idiv_clk & (1 << 5)) | 
					
						
							|  |  |  | 			rate /= 128; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			rate /= 16; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* CLKCx calculation */ | 
					
						
							| 
									
										
										
										
											2013-10-14 10:35:42 +09:00
										 |  |  | 		rate /= (((idiv_clk & 0x1F) + 1) * 2); | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* save best settings */ | 
					
						
							| 
									
										
										
										
											2014-03-02 23:01:50 +08:00
										 |  |  | 		tmp = abs(t->speed_hz - rate); | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 		if (tmp < min) { | 
					
						
							|  |  |  | 			min = tmp; | 
					
						
							|  |  |  | 			spcr = idiv_clk; | 
					
						
							|  |  |  | 			best_rate = rate; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (spi->mode & SPI_CPHA) | 
					
						
							|  |  |  | 		spcr |= 1 << 7; | 
					
						
							|  |  |  | 	if (spi->mode & SPI_CPOL) | 
					
						
							|  |  |  | 		spcr |= 1 << 6; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-02 23:01:50 +08:00
										 |  |  | 	dev_dbg(dev, "speed %d/%d\n", t->speed_hz, best_rate); | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	hspi_write(hspi, SPCR, spcr); | 
					
						
							|  |  |  | 	hspi_write(hspi, SPSR, 0x0); | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | 	hspi_write(hspi, SPSCR, 0x21);	/* master mode / CS control */ | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | static int hspi_transfer_one_message(struct spi_master *master, | 
					
						
							|  |  |  | 				     struct spi_message *msg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct hspi_priv *hspi = spi_master_get_devdata(master); | 
					
						
							|  |  |  | 	struct spi_transfer *t; | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:25 -07:00
										 |  |  | 	u32 tx; | 
					
						
							|  |  |  | 	u32 rx; | 
					
						
							|  |  |  | 	int ret, i; | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | 	unsigned int cs_change; | 
					
						
							|  |  |  | 	const int nsecs = 50; | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 	dev_dbg(hspi->dev, "%s\n", __func__); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | 	cs_change = 1; | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 	ret = 0; | 
					
						
							|  |  |  | 	list_for_each_entry(t, &msg->transfers, transfer_list) { | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (cs_change) { | 
					
						
							|  |  |  | 			hspi_hw_setup(hspi, msg, t); | 
					
						
							|  |  |  | 			hspi_hw_cs_enable(hspi); | 
					
						
							|  |  |  | 			ndelay(nsecs); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		cs_change = t->cs_change; | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:25 -07:00
										 |  |  | 		for (i = 0; i < t->len; i++) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* wait remains */ | 
					
						
							|  |  |  | 			ret = hspi_status_check_timeout(hspi, 0x1, 0); | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 			if (ret < 0) | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:25 -07:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			tx = 0; | 
					
						
							|  |  |  | 			if (t->tx_buf) | 
					
						
							|  |  |  | 				tx = (u32)((u8 *)t->tx_buf)[i]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			hspi_write(hspi, SPTBR, tx); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-12 14:03:38 +01:00
										 |  |  | 			/* wait receive */ | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:25 -07:00
										 |  |  | 			ret = hspi_status_check_timeout(hspi, 0x4, 0x4); | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 			if (ret < 0) | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:25 -07:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			rx = hspi_read(hspi, SPRBR); | 
					
						
							|  |  |  | 			if (t->rx_buf) | 
					
						
							|  |  |  | 				((u8 *)t->rx_buf)[i] = (u8)rx; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:25 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 		msg->actual_length += t->len; | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if (t->delay_usecs) | 
					
						
							|  |  |  | 			udelay(t->delay_usecs); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (cs_change) { | 
					
						
							|  |  |  | 			ndelay(nsecs); | 
					
						
							|  |  |  | 			hspi_hw_cs_disable(hspi); | 
					
						
							|  |  |  | 			ndelay(nsecs); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 	msg->status = ret; | 
					
						
							| 
									
										
										
										
											2012-11-22 14:37:27 +00:00
										 |  |  | 	if (!cs_change) { | 
					
						
							|  |  |  | 		ndelay(nsecs); | 
					
						
							|  |  |  | 		hspi_hw_cs_disable(hspi); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 	spi_finalize_current_message(master); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 	return ret; | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-07 16:57:14 +00:00
										 |  |  | static int hspi_probe(struct platform_device *pdev) | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct resource *res; | 
					
						
							|  |  |  | 	struct spi_master *master; | 
					
						
							|  |  |  | 	struct hspi_priv *hspi; | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 	struct clk *clk; | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* get base addr */ | 
					
						
							|  |  |  | 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 
					
						
							|  |  |  | 	if (!res) { | 
					
						
							|  |  |  | 		dev_err(&pdev->dev, "invalid resource\n"); | 
					
						
							|  |  |  | 		return -EINVAL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	master = spi_alloc_master(&pdev->dev, sizeof(*hspi)); | 
					
						
							|  |  |  | 	if (!master) { | 
					
						
							|  |  |  | 		dev_err(&pdev->dev, "spi_alloc_master error.\n"); | 
					
						
							|  |  |  | 		return -ENOMEM; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-14 10:41:38 +09:00
										 |  |  | 	clk = clk_get(&pdev->dev, NULL); | 
					
						
							| 
									
										
										
										
											2012-12-12 01:24:54 +01:00
										 |  |  | 	if (IS_ERR(clk)) { | 
					
						
							| 
									
										
										
										
											2014-04-14 10:41:38 +09:00
										 |  |  | 		dev_err(&pdev->dev, "couldn't get clock\n"); | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 		ret = -EINVAL; | 
					
						
							|  |  |  | 		goto error0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	hspi = spi_master_get_devdata(master); | 
					
						
							| 
									
										
										
										
											2013-05-23 19:20:40 +09:00
										 |  |  | 	platform_set_drvdata(pdev, hspi); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* init hspi */ | 
					
						
							|  |  |  | 	hspi->master	= master; | 
					
						
							|  |  |  | 	hspi->dev	= &pdev->dev; | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 	hspi->clk	= clk; | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	hspi->addr	= devm_ioremap(hspi->dev, | 
					
						
							|  |  |  | 				       res->start, resource_size(res)); | 
					
						
							|  |  |  | 	if (!hspi->addr) { | 
					
						
							|  |  |  | 		dev_err(&pdev->dev, "ioremap error.\n"); | 
					
						
							|  |  |  | 		ret = -ENOMEM; | 
					
						
							|  |  |  | 		goto error1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-03 02:15:50 -07:00
										 |  |  | 	pm_runtime_enable(&pdev->dev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	master->bus_num		= pdev->id; | 
					
						
							|  |  |  | 	master->mode_bits	= SPI_CPOL | SPI_CPHA; | 
					
						
							| 
									
										
										
										
											2013-10-24 21:53:29 -07:00
										 |  |  | 	master->dev.of_node	= pdev->dev.of_node; | 
					
						
							| 
									
										
										
										
											2013-07-28 15:35:36 +01:00
										 |  |  | 	master->auto_runtime_pm = true; | 
					
						
							| 
									
										
										
										
											2012-03-14 02:47:40 -07:00
										 |  |  | 	master->transfer_one_message		= hspi_transfer_one_message; | 
					
						
							| 
									
										
										
										
											2014-02-12 22:09:52 +08:00
										 |  |  | 	master->bits_per_word_mask = SPI_BPW_MASK(8); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-24 13:47:59 +09:00
										 |  |  | 	ret = devm_spi_register_master(&pdev->dev, master); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	if (ret < 0) { | 
					
						
							|  |  |  | 		dev_err(&pdev->dev, "spi_register_master error.\n"); | 
					
						
							| 
									
										
										
										
											2014-03-11 10:59:10 +01:00
										 |  |  | 		goto error2; | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-11 10:59:10 +01:00
										 |  |  |  error2: | 
					
						
							|  |  |  | 	pm_runtime_disable(&pdev->dev); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  |  error1: | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 	clk_put(clk); | 
					
						
							|  |  |  |  error0: | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	spi_master_put(master); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-07 16:57:14 +00:00
										 |  |  | static int hspi_remove(struct platform_device *pdev) | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-23 19:20:40 +09:00
										 |  |  | 	struct hspi_priv *hspi = platform_get_drvdata(pdev); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	pm_runtime_disable(&pdev->dev); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 02:48:05 -07:00
										 |  |  | 	clk_put(hspi->clk); | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-03 21:04:59 +09:00
										 |  |  | static const struct of_device_id hspi_of_match[] = { | 
					
						
							| 
									
										
										
										
											2013-10-24 21:53:29 -07:00
										 |  |  | 	{ .compatible = "renesas,hspi", }, | 
					
						
							|  |  |  | 	{ /* sentinel */ } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | MODULE_DEVICE_TABLE(of, hspi_of_match); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | static struct platform_driver hspi_driver = { | 
					
						
							|  |  |  | 	.probe = hspi_probe, | 
					
						
							| 
									
										
										
										
											2012-12-07 16:57:14 +00:00
										 |  |  | 	.remove = hspi_remove, | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	.driver = { | 
					
						
							|  |  |  | 		.name = "sh-hspi", | 
					
						
							|  |  |  | 		.owner = THIS_MODULE, | 
					
						
							| 
									
										
										
										
											2013-10-24 21:53:29 -07:00
										 |  |  | 		.of_match_table = hspi_of_match, | 
					
						
							| 
									
										
										
										
											2012-03-01 17:10:17 -08:00
										 |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | module_platform_driver(hspi_driver); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MODULE_DESCRIPTION("SuperH HSPI bus driver"); | 
					
						
							|  |  |  | MODULE_LICENSE("GPL"); | 
					
						
							|  |  |  | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); | 
					
						
							| 
									
										
										
										
											2014-01-08 18:52:40 +08:00
										 |  |  | MODULE_ALIAS("platform:sh-hspi"); |