Skip to content

Commit

Permalink
PM / devfreq: exynos: make more PPMU code common
Browse files Browse the repository at this point in the history
Move common PPMU code from exynos[45]_bus.c to exynos_ppmu.c.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
  • Loading branch information
Bartlomiej Zolnierkiewicz authored and MyungJoo Ham committed May 24, 2014
1 parent a94f6b4 commit 26d5185
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 136 deletions.
70 changes: 2 additions & 68 deletions drivers/devfreq/exynos/exynos4_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ struct busfreq_opp_info {
unsigned long volt;
};

struct busfreq_ppmu_data {
struct exynos_ppmu *ppmu;
int ppmu_end;
};

struct busfreq_data {
enum exynos4_busf_type type;
struct device *dev;
Expand Down Expand Up @@ -515,49 +510,6 @@ static int exynos4x12_set_busclk(struct busfreq_data *data,
return 0;
}

static void busfreq_mon_reset(struct busfreq_ppmu_data *ppmu_data)
{
unsigned int i;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base;

/* Reset the performance and cycle counters */
exynos_ppmu_reset(ppmu_base);

/* Setup count registers to monitor read/write transactions */
ppmu_data->ppmu[i].event[PPMU_PMNCNT3] = RDWR_DATA_COUNT;
exynos_ppmu_setevent(ppmu_base, PPMU_PMNCNT3,
ppmu_data->ppmu[i].event[PPMU_PMNCNT3]);

exynos_ppmu_start(ppmu_base);
}
}

static void exynos4_read_ppmu(struct busfreq_ppmu_data *ppmu_data)
{
int i, j;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base;

exynos_ppmu_stop(ppmu_base);

/* Update local data from PPMU */
ppmu_data->ppmu[i].ccnt = __raw_readl(ppmu_base + PPMU_CCNT);

for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) {
if (ppmu_data->ppmu[i].event[j] == 0)
ppmu_data->ppmu[i].count[j] = 0;
else
ppmu_data->ppmu[i].count[j] =
exynos_ppmu_read(ppmu_base, j);
}
}

busfreq_mon_reset(ppmu_data);
}

static int exynos4x12_get_intspec(unsigned long mifclk)
{
int i = 0;
Expand Down Expand Up @@ -681,33 +633,15 @@ static int exynos4_bus_target(struct device *dev, unsigned long *_freq,
return err;
}

static int exynos4_get_busier_ppmu(struct busfreq_ppmu_data *ppmu_data)
{
int i, j;
int busy = 0;
unsigned int temp = 0;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) {
if (ppmu_data->ppmu[i].count[j] > temp) {
temp = ppmu_data->ppmu[i].count[j];
busy = i;
}
}
}

return busy;
}

static int exynos4_bus_get_dev_status(struct device *dev,
struct devfreq_dev_status *stat)
{
struct busfreq_data *data = dev_get_drvdata(dev);
struct busfreq_ppmu_data *ppmu_data = &data->ppmu_data;
int busier;

exynos4_read_ppmu(ppmu_data);
busier = exynos4_get_busier_ppmu(ppmu_data);
exynos_read_ppmu(ppmu_data);
busier = exynos_get_busier_ppmu(ppmu_data);
stat->current_frequency = data->curr_oppinfo.rate;

/* Number of cycles spent on memory access */
Expand Down
70 changes: 2 additions & 68 deletions drivers/devfreq/exynos/exynos5_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ enum exynos_ppmu_list {
PPMU_END,
};

struct busfreq_ppmu_data {
struct exynos_ppmu *ppmu;
int ppmu_end;
};

struct busfreq_data_int {
struct device *dev;
struct devfreq *devfreq;
Expand Down Expand Up @@ -80,49 +75,6 @@ static struct int_bus_opp_table exynos5_int_opp_table[] = {
{0, 0, 0},
};

static void busfreq_mon_reset(struct busfreq_ppmu_data *ppmu_data)
{
unsigned int i;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base;

/* Reset the performance and cycle counters */
exynos_ppmu_reset(ppmu_base);

/* Setup count registers to monitor read/write transactions */
ppmu_data->ppmu[i].event[PPMU_PMNCNT3] = RDWR_DATA_COUNT;
exynos_ppmu_setevent(ppmu_base, PPMU_PMNCNT3,
ppmu_data->ppmu[i].event[PPMU_PMNCNT3]);

exynos_ppmu_start(ppmu_base);
}
}

static void exynos5_read_ppmu(struct busfreq_ppmu_data *ppmu_data)
{
int i, j;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base;

exynos_ppmu_stop(ppmu_base);

/* Update local data from PPMU */
ppmu_data->ppmu[i].ccnt = __raw_readl(ppmu_base + PPMU_CCNT);

for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) {
if (ppmu_data->ppmu[i].event[j] == 0)
ppmu_data->ppmu[i].count[j] = 0;
else
ppmu_data->ppmu[i].count[j] =
exynos_ppmu_read(ppmu_base, j);
}
}

busfreq_mon_reset(ppmu_data);
}

static int exynos5_int_setvolt(struct busfreq_data_int *data,
unsigned long volt)
{
Expand Down Expand Up @@ -190,24 +142,6 @@ static int exynos5_busfreq_int_target(struct device *dev, unsigned long *_freq,
return err;
}

static int exynos5_get_busier_dmc(struct busfreq_ppmu_data *ppmu_data)
{
int i, j;
int busy = 0;
unsigned int temp = 0;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) {
if (ppmu_data->ppmu[i].count[j] > temp) {
temp = ppmu_data->ppmu[i].count[j];
busy = i;
}
}
}

return busy;
}

static int exynos5_int_get_dev_status(struct device *dev,
struct devfreq_dev_status *stat)
{
Expand All @@ -217,8 +151,8 @@ static int exynos5_int_get_dev_status(struct device *dev,
struct busfreq_ppmu_data *ppmu_data = &data->ppmu_data;
int busier_dmc;

exynos5_read_ppmu(ppmu_data);
busier_dmc = exynos5_get_busier_dmc(ppmu_data);
exynos_read_ppmu(ppmu_data);
busier_dmc = exynos_get_busier_ppmu(ppmu_data);

stat->current_frequency = data->curr_freq;

Expand Down
60 changes: 60 additions & 0 deletions drivers/devfreq/exynos/exynos_ppmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,63 @@ unsigned int exynos_ppmu_read(void __iomem *ppmu_base, unsigned int ch)

return total;
}

void busfreq_mon_reset(struct busfreq_ppmu_data *ppmu_data)
{
unsigned int i;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base;

/* Reset the performance and cycle counters */
exynos_ppmu_reset(ppmu_base);

/* Setup count registers to monitor read/write transactions */
ppmu_data->ppmu[i].event[PPMU_PMNCNT3] = RDWR_DATA_COUNT;
exynos_ppmu_setevent(ppmu_base, PPMU_PMNCNT3,
ppmu_data->ppmu[i].event[PPMU_PMNCNT3]);

exynos_ppmu_start(ppmu_base);
}
}

void exynos_read_ppmu(struct busfreq_ppmu_data *ppmu_data)
{
int i, j;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base;

exynos_ppmu_stop(ppmu_base);

/* Update local data from PPMU */
ppmu_data->ppmu[i].ccnt = __raw_readl(ppmu_base + PPMU_CCNT);

for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) {
if (ppmu_data->ppmu[i].event[j] == 0)
ppmu_data->ppmu[i].count[j] = 0;
else
ppmu_data->ppmu[i].count[j] =
exynos_ppmu_read(ppmu_base, j);
}
}

busfreq_mon_reset(ppmu_data);
}

int exynos_get_busier_ppmu(struct busfreq_ppmu_data *ppmu_data)
{
unsigned int count = 0;
int i, j, busy = 0;

for (i = 0; i < ppmu_data->ppmu_end; i++) {
for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) {
if (ppmu_data->ppmu[i].count[j] > count) {
count = ppmu_data->ppmu[i].count[j];
busy = i;
}
}
}

return busy;
}
8 changes: 8 additions & 0 deletions drivers/devfreq/exynos/exynos_ppmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,18 @@ struct exynos_ppmu {
bool count_overflow[PPMU_PMNCNT_MAX];
};

struct busfreq_ppmu_data {
struct exynos_ppmu *ppmu;
int ppmu_end;
};

void exynos_ppmu_reset(void __iomem *ppmu_base);
void exynos_ppmu_setevent(void __iomem *ppmu_base, unsigned int ch,
unsigned int evt);
void exynos_ppmu_start(void __iomem *ppmu_base);
void exynos_ppmu_stop(void __iomem *ppmu_base);
unsigned int exynos_ppmu_read(void __iomem *ppmu_base, unsigned int ch);
void busfreq_mon_reset(struct busfreq_ppmu_data *ppmu_data);
void exynos_read_ppmu(struct busfreq_ppmu_data *ppmu_data);
int exynos_get_busier_ppmu(struct busfreq_ppmu_data *ppmu_data);
#endif /* __DEVFREQ_EXYNOS_PPMU_H */

0 comments on commit 26d5185

Please sign in to comment.