Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5947c167 authored by Wei WANG's avatar Wei WANG Committed by Samuel Ortiz
Browse files

mfd: rtsx: Add shutdown callback in rtsx_pci_driver



Some actions to clear power state should be handled in .shutdown
callback in rtsx_pci_driver. This patch adopts the following measures to
catch this goal:
1. Add a function rtsx_pci_power_off to abstract the common ops in
.shutdown and .suspend
2. Add pcr->ops->force_power_down to fulfill the individual action for
each reader model

Signed-off-by: default avatarWei WANG <wei_wang@realsil.com.cn>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 773ccdfd
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -86,6 +86,11 @@ static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr *pcr)
		map_sd_drive(rtl8411b_reg_to_sd30_drive_sel_3v3(reg));
		map_sd_drive(rtl8411b_reg_to_sd30_drive_sel_3v3(reg));
}
}


static void rtl8411_force_power_down(struct rtsx_pcr *pcr)
{
	rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07);
}

static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr)
static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr)
{
{
	rtsx_pci_init_cmd(pcr);
	rtsx_pci_init_cmd(pcr);
@@ -285,6 +290,7 @@ static const struct pcr_ops rtl8411_pcr_ops = {
	.switch_output_voltage = rtl8411_switch_output_voltage,
	.switch_output_voltage = rtl8411_switch_output_voltage,
	.cd_deglitch = rtl8411_cd_deglitch,
	.cd_deglitch = rtl8411_cd_deglitch,
	.conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
	.conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
	.force_power_down = rtl8411_force_power_down,
};
};


static const struct pcr_ops rtl8411b_pcr_ops = {
static const struct pcr_ops rtl8411b_pcr_ops = {
@@ -300,6 +306,7 @@ static const struct pcr_ops rtl8411b_pcr_ops = {
	.switch_output_voltage = rtl8411_switch_output_voltage,
	.switch_output_voltage = rtl8411_switch_output_voltage,
	.cd_deglitch = rtl8411_cd_deglitch,
	.cd_deglitch = rtl8411_cd_deglitch,
	.conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
	.conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
	.force_power_down = rtl8411_force_power_down,
};
};


/* SD Pull Control Enable:
/* SD Pull Control Enable:
+6 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,11 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr *pcr)
	}
	}
}
}


static void rts5209_force_power_down(struct rtsx_pcr *pcr)
{
	rtsx_pci_write_register(pcr, FPDCTL, 0x07, 0x07);
}

static int rts5209_extra_init_hw(struct rtsx_pcr *pcr)
static int rts5209_extra_init_hw(struct rtsx_pcr *pcr)
{
{
	rtsx_pci_init_cmd(pcr);
	rtsx_pci_init_cmd(pcr);
@@ -197,6 +202,7 @@ static const struct pcr_ops rts5209_pcr_ops = {
	.switch_output_voltage = rts5209_switch_output_voltage,
	.switch_output_voltage = rts5209_switch_output_voltage,
	.cd_deglitch = NULL,
	.cd_deglitch = NULL,
	.conv_clk_and_div_n = NULL,
	.conv_clk_and_div_n = NULL,
	.force_power_down = rts5209_force_power_down,
};
};


/* SD Pull Control Enable:
/* SD Pull Control Enable:
+11 −0
Original line number Original line Diff line number Diff line
@@ -83,6 +83,16 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr)
		pcr->flags |= PCR_REVERSE_SOCKET;
		pcr->flags |= PCR_REVERSE_SOCKET;
}
}


static void rts5227_force_power_down(struct rtsx_pcr *pcr)
{
	/* Set relink_time to 0 */
	rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
	rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
	rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);

	rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
}

static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
{
{
	u16 cap;
	u16 cap;
@@ -218,6 +228,7 @@ static const struct pcr_ops rts5227_pcr_ops = {
	.switch_output_voltage = rts5227_switch_output_voltage,
	.switch_output_voltage = rts5227_switch_output_voltage,
	.cd_deglitch = NULL,
	.cd_deglitch = NULL,
	.conv_clk_and_div_n = NULL,
	.conv_clk_and_div_n = NULL,
	.force_power_down = rts5227_force_power_down,
};
};


/* SD Pull Control Enable:
/* SD Pull Control Enable:
+6 −0
Original line number Original line Diff line number Diff line
@@ -56,6 +56,11 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr *pcr)
		map_sd_drive(rtsx_reg_to_sd30_drive_sel_3v3(reg));
		map_sd_drive(rtsx_reg_to_sd30_drive_sel_3v3(reg));
}
}


static void rts5229_force_power_down(struct rtsx_pcr *pcr)
{
	rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
}

static int rts5229_extra_init_hw(struct rtsx_pcr *pcr)
static int rts5229_extra_init_hw(struct rtsx_pcr *pcr)
{
{
	rtsx_pci_init_cmd(pcr);
	rtsx_pci_init_cmd(pcr);
@@ -179,6 +184,7 @@ static const struct pcr_ops rts5229_pcr_ops = {
	.switch_output_voltage = rts5229_switch_output_voltage,
	.switch_output_voltage = rts5229_switch_output_voltage,
	.cd_deglitch = NULL,
	.cd_deglitch = NULL,
	.conv_clk_and_div_n = NULL,
	.conv_clk_and_div_n = NULL,
	.force_power_down = rts5229_force_power_down,
};
};


/* SD Pull Control Enable:
/* SD Pull Control Enable:
+11 −0
Original line number Original line Diff line number Diff line
@@ -88,6 +88,16 @@ static void rts5249_fetch_vendor_settings(struct rtsx_pcr *pcr)
		pcr->flags |= PCR_REVERSE_SOCKET;
		pcr->flags |= PCR_REVERSE_SOCKET;
}
}


static void rts5249_force_power_down(struct rtsx_pcr *pcr)
{
	/* Set relink_time to 0 */
	rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
	rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
	rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);

	rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
}

static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
{
{
	rtsx_pci_init_cmd(pcr);
	rtsx_pci_init_cmd(pcr);
@@ -217,6 +227,7 @@ static const struct pcr_ops rts5249_pcr_ops = {
	.card_power_on = rts5249_card_power_on,
	.card_power_on = rts5249_card_power_on,
	.card_power_off = rts5249_card_power_off,
	.card_power_off = rts5249_card_power_off,
	.switch_output_voltage = rts5249_switch_output_voltage,
	.switch_output_voltage = rts5249_switch_output_voltage,
	.force_power_down = rts5249_force_power_down,
};
};


/* SD Pull Control Enable:
/* SD Pull Control Enable:
Loading