Skip to content

Commit

Permalink
ARM: SAMSUNG: Reduce size of struct clk.
Browse files Browse the repository at this point in the history
Reduce the size of struct clk by 12 bytes and make defining clocks with
common implementation functions easier by moving the set_rate, get_rate,
round_rate and set_parent calls into a new structure called 'struct clk_ops'
and using that instead.

This change does make a few clocks larger as they need their own clk_ops,
but this is outweighed by the number of clocks with either no ops or having
a common set of ops.

Update all the users of this.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Ben Dooks committed Jan 15, 2010
1 parent 13bbd88 commit b3bf41b
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 211 deletions.
52 changes: 33 additions & 19 deletions arch/arm/mach-s3c2412/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ static struct clk clk_usysclk = {
.name = "usysclk",
.id = -1,
.parent = &clk_xtal,
.set_parent = s3c2412_setparent_usysclk,
.ops = &(struct clk_ops) {
.set_parent = s3c2412_setparent_usysclk,
},
};

static struct clk clk_mrefclk = {
Expand Down Expand Up @@ -199,10 +201,12 @@ static int s3c2412_setrate_usbsrc(struct clk *clk, unsigned long rate)
static struct clk clk_usbsrc = {
.name = "usbsrc",
.id = -1,
.get_rate = s3c2412_getrate_usbsrc,
.set_rate = s3c2412_setrate_usbsrc,
.round_rate = s3c2412_roundrate_usbsrc,
.set_parent = s3c2412_setparent_usbsrc,
.ops = &(struct clk_ops) {
.get_rate = s3c2412_getrate_usbsrc,
.set_rate = s3c2412_setrate_usbsrc,
.round_rate = s3c2412_roundrate_usbsrc,
.set_parent = s3c2412_setparent_usbsrc,
},
};

static int s3c2412_setparent_msysclk(struct clk *clk, struct clk *parent)
Expand All @@ -225,7 +229,9 @@ static int s3c2412_setparent_msysclk(struct clk *clk, struct clk *parent)
static struct clk clk_msysclk = {
.name = "msysclk",
.id = -1,
.set_parent = s3c2412_setparent_msysclk,
.ops = &(struct clk_ops) {
.set_parent = s3c2412_setparent_msysclk,
},
};

static int s3c2412_setparent_armclk(struct clk *clk, struct clk *parent)
Expand Down Expand Up @@ -264,7 +270,9 @@ static struct clk clk_armclk = {
.name = "armclk",
.id = -1,
.parent = &clk_msysclk,
.set_parent = s3c2412_setparent_armclk,
.ops = &(struct clk_ops) {
.set_parent = s3c2412_setparent_armclk,
},
};

/* these next clocks have an divider immediately after them,
Expand Down Expand Up @@ -337,10 +345,12 @@ static int s3c2412_setrate_uart(struct clk *clk, unsigned long rate)
static struct clk clk_uart = {
.name = "uartclk",
.id = -1,
.get_rate = s3c2412_getrate_uart,
.set_rate = s3c2412_setrate_uart,
.set_parent = s3c2412_setparent_uart,
.round_rate = s3c2412_roundrate_clksrc,
.ops = &(struct clk_ops) {
.get_rate = s3c2412_getrate_uart,
.set_rate = s3c2412_setrate_uart,
.set_parent = s3c2412_setparent_uart,
.round_rate = s3c2412_roundrate_clksrc,
},
};

static int s3c2412_setparent_i2s(struct clk *clk, struct clk *parent)
Expand Down Expand Up @@ -388,10 +398,12 @@ static int s3c2412_setrate_i2s(struct clk *clk, unsigned long rate)
static struct clk clk_i2s = {
.name = "i2sclk",
.id = -1,
.get_rate = s3c2412_getrate_i2s,
.set_rate = s3c2412_setrate_i2s,
.set_parent = s3c2412_setparent_i2s,
.round_rate = s3c2412_roundrate_clksrc,
.ops = &(struct clk_ops) {
.get_rate = s3c2412_getrate_i2s,
.set_rate = s3c2412_setrate_i2s,
.set_parent = s3c2412_setparent_i2s,
.round_rate = s3c2412_roundrate_clksrc,
},
};

static int s3c2412_setparent_cam(struct clk *clk, struct clk *parent)
Expand Down Expand Up @@ -438,10 +450,12 @@ static int s3c2412_setrate_cam(struct clk *clk, unsigned long rate)
static struct clk clk_cam = {
.name = "camif-upll", /* same as 2440 name */
.id = -1,
.get_rate = s3c2412_getrate_cam,
.set_rate = s3c2412_setrate_cam,
.set_parent = s3c2412_setparent_cam,
.round_rate = s3c2412_roundrate_clksrc,
.ops = &(struct clk_ops) {
.get_rate = s3c2412_getrate_cam,
.set_rate = s3c2412_setrate_cam,
.set_parent = s3c2412_setparent_cam,
.round_rate = s3c2412_roundrate_clksrc,
},
};

/* standard clock definitions */
Expand Down
6 changes: 4 additions & 2 deletions arch/arm/mach-s3c2440/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ static struct clk s3c2440_clk_cam = {
static struct clk s3c2440_clk_cam_upll = {
.name = "camif-upll",
.id = -1,
.set_rate = s3c2440_camif_upll_setrate,
.round_rate = s3c2440_camif_upll_round,
.ops = &(struct clk_ops) {
.set_rate = s3c2440_camif_upll_setrate,
.round_rate = s3c2440_camif_upll_round,
},
};

static struct clk s3c2440_clk_ac97 = {
Expand Down
6 changes: 4 additions & 2 deletions arch/arm/mach-s3c2442/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ static struct clk s3c2442_clk_cam = {
static struct clk s3c2442_clk_cam_upll = {
.name = "camif-upll",
.id = -1,
.set_rate = s3c2442_camif_upll_setrate,
.round_rate = s3c2442_camif_upll_round,
.ops = &(struct clk_ops) {
.set_rate = s3c2442_camif_upll_setrate,
.round_rate = s3c2442_camif_upll_round,
},
};

static int s3c2442_clk_add(struct sys_device *sysdev)
Expand Down
88 changes: 59 additions & 29 deletions arch/arm/mach-s3c2443/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ static int s3c2443_setparent_epllref(struct clk *clk, struct clk *parent)
static struct clk clk_epllref = {
.name = "epllref",
.id = -1,
.set_parent = s3c2443_setparent_epllref,
.ops = &(struct clk_ops) {
.set_parent = s3c2443_setparent_epllref,
},
};

static unsigned long s3c2443_getrate_mdivclk(struct clk *clk)
Expand All @@ -205,7 +207,9 @@ static struct clk clk_mdivclk = {
.name = "mdivclk",
.parent = &clk_mpllref,
.id = -1,
.get_rate = s3c2443_getrate_mdivclk,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_mdivclk,
},
};

static int s3c2443_setparent_msysclk(struct clk *clk, struct clk *parent)
Expand All @@ -232,7 +236,9 @@ static struct clk clk_msysclk = {
.name = "msysclk",
.parent = &clk_xtal,
.id = -1,
.set_parent = s3c2443_setparent_msysclk,
.ops = &(struct clk_ops) {
.set_parent = s3c2443_setparent_msysclk,
},
};

/* armdiv
Expand Down Expand Up @@ -273,7 +279,9 @@ static int s3c2443_setparent_armclk(struct clk *clk, struct clk *parent)
static struct clk clk_arm = {
.name = "armclk",
.id = -1,
.set_parent = s3c2443_setparent_armclk,
.ops = &(struct clk_ops) {
.set_parent = s3c2443_setparent_armclk,
},
};

/* esysclk
Expand Down Expand Up @@ -302,7 +310,9 @@ static struct clk clk_esysclk = {
.name = "esysclk",
.parent = &clk_epll,
.id = -1,
.set_parent = s3c2443_setparent_esysclk,
.ops = &(struct clk_ops) {
.set_parent = s3c2443_setparent_esysclk,
},
};

/* uartclk
Expand Down Expand Up @@ -341,9 +351,11 @@ static struct clk clk_uart = {
.name = "uartclk",
.id = -1,
.parent = &clk_esysclk,
.get_rate = s3c2443_getrate_uart,
.set_rate = s3c2443_setrate_uart,
.round_rate = s3c2443_roundrate_clksrc16,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_uart,
.set_rate = s3c2443_setrate_uart,
.round_rate = s3c2443_roundrate_clksrc16,
},
};

/* hsspi
Expand Down Expand Up @@ -384,9 +396,11 @@ static struct clk clk_hsspi = {
.parent = &clk_esysclk,
.ctrlbit = S3C2443_SCLKCON_HSSPICLK,
.enable = s3c2443_clkcon_enable_s,
.get_rate = s3c2443_getrate_hsspi,
.set_rate = s3c2443_setrate_hsspi,
.round_rate = s3c2443_roundrate_clksrc4,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_hsspi,
.set_rate = s3c2443_setrate_hsspi,
.round_rate = s3c2443_roundrate_clksrc4,
},
};

/* usbhost
Expand Down Expand Up @@ -426,9 +440,11 @@ static struct clk clk_usb_bus_host = {
.parent = &clk_esysclk,
.ctrlbit = S3C2443_SCLKCON_USBHOST,
.enable = s3c2443_clkcon_enable_s,
.get_rate = s3c2443_getrate_usbhost,
.set_rate = s3c2443_setrate_usbhost,
.round_rate = s3c2443_roundrate_clksrc4,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_usbhost,
.set_rate = s3c2443_setrate_usbhost,
.round_rate = s3c2443_roundrate_clksrc4,
},
};

/* clk_hsmcc_div
Expand Down Expand Up @@ -468,9 +484,11 @@ static struct clk clk_hsmmc_div = {
.name = "hsmmc-div",
.id = -1,
.parent = &clk_esysclk,
.get_rate = s3c2443_getrate_hsmmc_div,
.set_rate = s3c2443_setrate_hsmmc_div,
.round_rate = s3c2443_roundrate_clksrc4,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_hsmmc_div,
.set_rate = s3c2443_setrate_hsmmc_div,
.round_rate = s3c2443_roundrate_clksrc4,
},
};

static int s3c2443_setparent_hsmmc(struct clk *clk, struct clk *parent)
Expand Down Expand Up @@ -505,7 +523,9 @@ static struct clk clk_hsmmc = {
.id = -1,
.parent = &clk_hsmmc_div,
.enable = s3c2443_enable_hsmmc,
.set_parent = s3c2443_setparent_hsmmc,
.ops = &(struct clk_ops) {
.set_parent = s3c2443_setparent_hsmmc,
},
};

/* i2s_eplldiv
Expand Down Expand Up @@ -543,9 +563,11 @@ static struct clk clk_i2s_eplldiv = {
.name = "i2s-eplldiv",
.id = -1,
.parent = &clk_esysclk,
.get_rate = s3c2443_getrate_i2s_eplldiv,
.set_rate = s3c2443_setrate_i2s_eplldiv,
.round_rate = s3c2443_roundrate_clksrc16,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_i2s_eplldiv,
.set_rate = s3c2443_setrate_i2s_eplldiv,
.round_rate = s3c2443_roundrate_clksrc16,
},
};

/* i2s-ref
Expand Down Expand Up @@ -578,7 +600,9 @@ static struct clk clk_i2s = {
.parent = &clk_i2s_eplldiv,
.ctrlbit = S3C2443_SCLKCON_I2SCLK,
.enable = s3c2443_clkcon_enable_s,
.set_parent = s3c2443_setparent_i2s,
.ops = &(struct clk_ops) {
.set_parent = s3c2443_setparent_i2s,
},
};

/* cam-if
Expand Down Expand Up @@ -618,9 +642,11 @@ static struct clk clk_cam = {
.parent = &clk_esysclk,
.ctrlbit = S3C2443_SCLKCON_CAMCLK,
.enable = s3c2443_clkcon_enable_s,
.get_rate = s3c2443_getrate_cam,
.set_rate = s3c2443_setrate_cam,
.round_rate = s3c2443_roundrate_clksrc16,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_cam,
.set_rate = s3c2443_setrate_cam,
.round_rate = s3c2443_roundrate_clksrc16,
},
};

/* display-if
Expand Down Expand Up @@ -660,9 +686,11 @@ static struct clk clk_display = {
.parent = &clk_esysclk,
.ctrlbit = S3C2443_SCLKCON_DISPCLK,
.enable = s3c2443_clkcon_enable_s,
.get_rate = s3c2443_getrate_display,
.set_rate = s3c2443_setrate_display,
.round_rate = s3c2443_roundrate_clksrc256,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_getrate_display,
.set_rate = s3c2443_setrate_display,
.round_rate = s3c2443_roundrate_clksrc256,
},
};

/* prediv
Expand All @@ -685,7 +713,9 @@ static struct clk clk_prediv = {
.name = "prediv",
.id = -1,
.parent = &clk_msysclk,
.get_rate = s3c2443_prediv_getrate,
.ops = &(struct clk_ops) {
.get_rate = s3c2443_prediv_getrate,
},
};

/* standard clock definitions */
Expand Down
Loading

0 comments on commit b3bf41b

Please sign in to comment.