#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/spi/spi.h>
#include <linux/spi/sh_hspi.h>
struct spi_controller *ctlr;
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);
static void hspi_bit_set(struct hspi_priv *hspi, int reg, u32 mask, u32 set)
u32 val = hspi_read(hspi, reg);
hspi_write(hspi, reg, val);
static int hspi_status_check_timeout(struct hspi_priv *hspi, u32 mask, u32 val)
if ((mask & hspi_read(hspi, SPSR)) == val)
dev_err(hspi->dev, "timeout\n");
#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);