mmc: sdhci: move the callback function into sdhci_ops
callback function should be moved into sdhci_ops struct. Other controller can use these ops for controlling clock or their own specific register. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
This commit is contained in:
		
							parent
							
								
									f73b33ff94
								
							
						
					
					
						commit
						62226b6863
					
				|  | @ -79,6 +79,11 @@ static void s5p_set_clock(struct sdhci_host *host, u32 div) | ||||||
| 	set_mmc_clk(host->index, div); | 	set_mmc_clk(host->index, div); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static const struct sdhci_ops s5p_sdhci_ops = { | ||||||
|  | 	.set_clock	= &s5p_set_clock, | ||||||
|  | 	.set_control_reg = &s5p_sdhci_set_control_reg, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| static int s5p_sdhci_core_init(struct sdhci_host *host) | static int s5p_sdhci_core_init(struct sdhci_host *host) | ||||||
| { | { | ||||||
| 	host->name = S5P_NAME; | 	host->name = S5P_NAME; | ||||||
|  | @ -87,9 +92,7 @@ static int s5p_sdhci_core_init(struct sdhci_host *host) | ||||||
| 		SDHCI_QUIRK_32BIT_DMA_ADDR | | 		SDHCI_QUIRK_32BIT_DMA_ADDR | | ||||||
| 		SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; | 		SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; | ||||||
| 	host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; | 	host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; | ||||||
| 
 | 	host->ops = &s5p_sdhci_ops; | ||||||
| 	host->set_control_reg = &s5p_sdhci_set_control_reg; |  | ||||||
| 	host->set_clock = &s5p_set_clock; |  | ||||||
| 
 | 
 | ||||||
| 	if (host->bus_width == 8) | 	if (host->bus_width == 8) | ||||||
| 		host->host_caps |= MMC_MODE_8BIT; | 		host->host_caps |= MMC_MODE_8BIT; | ||||||
|  |  | ||||||
|  | @ -359,8 +359,8 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int clock) | ||||||
| 		div >>= 1; | 		div >>= 1; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (host->set_clock) | 	if (host->ops->set_clock) | ||||||
| 		host->set_clock(host->index, div); | 		host->ops->set_clock(host, div); | ||||||
| 
 | 
 | ||||||
| 	clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT; | 	clk |= (div & SDHCI_DIV_MASK) << SDHCI_DIVIDER_SHIFT; | ||||||
| 	clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN) | 	clk |= ((div & SDHCI_DIV_HI_MASK) >> SDHCI_DIV_MASK_LEN) | ||||||
|  | @ -430,8 +430,8 @@ static int sdhci_set_ios(struct mmc *mmc) | ||||||
| 	u32 ctrl; | 	u32 ctrl; | ||||||
| 	struct sdhci_host *host = mmc->priv; | 	struct sdhci_host *host = mmc->priv; | ||||||
| 
 | 
 | ||||||
| 	if (host->set_control_reg) | 	if (host->ops->set_control_reg) | ||||||
| 		host->set_control_reg(host); | 		host->ops->set_control_reg(host); | ||||||
| 
 | 
 | ||||||
| 	if (mmc->clock != host->clock) | 	if (mmc->clock != host->clock) | ||||||
| 		sdhci_set_clock(mmc, mmc->clock); | 		sdhci_set_clock(mmc, mmc->clock); | ||||||
|  |  | ||||||
|  | @ -227,14 +227,16 @@ struct sdhci_host; | ||||||
| #define SDHCI_DEFAULT_BOUNDARY_ARG	(7) | #define SDHCI_DEFAULT_BOUNDARY_ARG	(7) | ||||||
| struct sdhci_ops { | struct sdhci_ops { | ||||||
| #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | ||||||
| 	u32             (*read_l)(struct sdhci_host *host, int reg); | 	u32	(*read_l)(struct sdhci_host *host, int reg); | ||||||
| 	u16             (*read_w)(struct sdhci_host *host, int reg); | 	u16	(*read_w)(struct sdhci_host *host, int reg); | ||||||
| 	u8              (*read_b)(struct sdhci_host *host, int reg); | 	u8	(*read_b)(struct sdhci_host *host, int reg); | ||||||
| 	void            (*write_l)(struct sdhci_host *host, u32 val, int reg); | 	void	(*write_l)(struct sdhci_host *host, u32 val, int reg); | ||||||
| 	void            (*write_w)(struct sdhci_host *host, u16 val, int reg); | 	void	(*write_w)(struct sdhci_host *host, u16 val, int reg); | ||||||
| 	void            (*write_b)(struct sdhci_host *host, u8 val, int reg); | 	void	(*write_b)(struct sdhci_host *host, u8 val, int reg); | ||||||
| #endif | #endif | ||||||
| 	int		(*get_cd)(struct sdhci_host *host); | 	int	(*get_cd)(struct sdhci_host *host); | ||||||
|  | 	void	(*set_control_reg)(struct sdhci_host *host); | ||||||
|  | 	void	(*set_clock)(struct sdhci_host *host, u32 div); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| struct sdhci_host { | struct sdhci_host { | ||||||
|  | @ -253,8 +255,6 @@ struct sdhci_host { | ||||||
| 	struct gpio_desc pwr_gpio;	/* Power GPIO */ | 	struct gpio_desc pwr_gpio;	/* Power GPIO */ | ||||||
| 	struct gpio_desc cd_gpio;		/* Card Detect GPIO */ | 	struct gpio_desc cd_gpio;		/* Card Detect GPIO */ | ||||||
| 
 | 
 | ||||||
| 	void (*set_control_reg)(struct sdhci_host *host); |  | ||||||
| 	void (*set_clock)(int dev_index, unsigned int div); |  | ||||||
| 	uint	voltages; | 	uint	voltages; | ||||||
| 
 | 
 | ||||||
| 	struct mmc_config cfg; | 	struct mmc_config cfg; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue