···16071607 correct output device configuration.16081608 Its use is strongly discouraged.1609160916101610+config FB_VIA_X_COMPATIBILITY16111611+ bool "X server compatibility"16121612+ depends on FB_VIA16131613+ default n16141614+ help16151615+ This option reduces the functionality (power saving, ...) of the16161616+ framebuffer to avoid negative impact on the OpenChrome X server.16171617+ If you use any X server other than fbdev you should enable this16181618+ otherwise it should be safe to disable it and allow using all16191619+ features.16201620+16101621endif1611162216121623config FB_NEOMAGIC
···11+/*22+ * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.33+ * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.44+ * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>55+ *66+ * This program is free software; you can redistribute it and/or77+ * modify it under the terms of the GNU General Public88+ * License as published by the Free Software Foundation;99+ * either version 2, or (at your option) any later version.1010+ *1111+ * This program is distributed in the hope that it will be useful,1212+ * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even1313+ * the implied warranty of MERCHANTABILITY or FITNESS FOR1414+ * A PARTICULAR PURPOSE.See the GNU General Public License1515+ * for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc.,2020+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.2121+ */2222+/*2323+ * clock and PLL management functions2424+ */2525+2626+#include <linux/kernel.h>2727+#include <linux/via-core.h>2828+#include "via_clock.h"2929+#include "global.h"3030+#include "debug.h"3131+3232+const char *via_slap = "Please slap VIA Technologies to motivate them "3333+ "releasing full documentation for your platform!\n";3434+3535+static inline u32 cle266_encode_pll(struct via_pll_config pll)3636+{3737+ return (pll.multiplier << 8)3838+ | (pll.rshift << 6)3939+ | pll.divisor;4040+}4141+4242+static inline u32 k800_encode_pll(struct via_pll_config pll)4343+{4444+ return ((pll.divisor - 2) << 16)4545+ | (pll.rshift << 10)4646+ | (pll.multiplier - 2);4747+}4848+4949+static inline u32 vx855_encode_pll(struct via_pll_config pll)5050+{5151+ return (pll.divisor << 16)5252+ | (pll.rshift << 10)5353+ | pll.multiplier;5454+}5555+5656+static inline void cle266_set_primary_pll_encoded(u32 data)5757+{5858+ via_write_reg_mask(VIASR, 0x40, 0x02, 0x02); /* enable reset */5959+ via_write_reg(VIASR, 0x46, data & 0xFF);6060+ via_write_reg(VIASR, 0x47, (data >> 8) & 0xFF);6161+ via_write_reg_mask(VIASR, 0x40, 0x00, 0x02); /* disable reset */6262+}6363+6464+static inline void k800_set_primary_pll_encoded(u32 data)6565+{6666+ via_write_reg_mask(VIASR, 0x40, 0x02, 0x02); /* enable reset */6767+ via_write_reg(VIASR, 0x44, data & 0xFF);6868+ via_write_reg(VIASR, 0x45, (data >> 8) & 0xFF);6969+ via_write_reg(VIASR, 0x46, (data >> 16) & 0xFF);7070+ via_write_reg_mask(VIASR, 0x40, 0x00, 0x02); /* disable reset */7171+}7272+7373+static inline void cle266_set_secondary_pll_encoded(u32 data)7474+{7575+ via_write_reg_mask(VIASR, 0x40, 0x04, 0x04); /* enable reset */7676+ via_write_reg(VIASR, 0x44, data & 0xFF);7777+ via_write_reg(VIASR, 0x45, (data >> 8) & 0xFF);7878+ via_write_reg_mask(VIASR, 0x40, 0x00, 0x04); /* disable reset */7979+}8080+8181+static inline void k800_set_secondary_pll_encoded(u32 data)8282+{8383+ via_write_reg_mask(VIASR, 0x40, 0x04, 0x04); /* enable reset */8484+ via_write_reg(VIASR, 0x4A, data & 0xFF);8585+ via_write_reg(VIASR, 0x4B, (data >> 8) & 0xFF);8686+ via_write_reg(VIASR, 0x4C, (data >> 16) & 0xFF);8787+ via_write_reg_mask(VIASR, 0x40, 0x00, 0x04); /* disable reset */8888+}8989+9090+static inline void set_engine_pll_encoded(u32 data)9191+{9292+ via_write_reg_mask(VIASR, 0x40, 0x01, 0x01); /* enable reset */9393+ via_write_reg(VIASR, 0x47, data & 0xFF);9494+ via_write_reg(VIASR, 0x48, (data >> 8) & 0xFF);9595+ via_write_reg(VIASR, 0x49, (data >> 16) & 0xFF);9696+ via_write_reg_mask(VIASR, 0x40, 0x00, 0x01); /* disable reset */9797+}9898+9999+static void cle266_set_primary_pll(struct via_pll_config config)100100+{101101+ cle266_set_primary_pll_encoded(cle266_encode_pll(config));102102+}103103+104104+static void k800_set_primary_pll(struct via_pll_config config)105105+{106106+ k800_set_primary_pll_encoded(k800_encode_pll(config));107107+}108108+109109+static void vx855_set_primary_pll(struct via_pll_config config)110110+{111111+ k800_set_primary_pll_encoded(vx855_encode_pll(config));112112+}113113+114114+static void cle266_set_secondary_pll(struct via_pll_config config)115115+{116116+ cle266_set_secondary_pll_encoded(cle266_encode_pll(config));117117+}118118+119119+static void k800_set_secondary_pll(struct via_pll_config config)120120+{121121+ k800_set_secondary_pll_encoded(k800_encode_pll(config));122122+}123123+124124+static void vx855_set_secondary_pll(struct via_pll_config config)125125+{126126+ k800_set_secondary_pll_encoded(vx855_encode_pll(config));127127+}128128+129129+static void k800_set_engine_pll(struct via_pll_config config)130130+{131131+ set_engine_pll_encoded(k800_encode_pll(config));132132+}133133+134134+static void vx855_set_engine_pll(struct via_pll_config config)135135+{136136+ set_engine_pll_encoded(vx855_encode_pll(config));137137+}138138+139139+static void set_primary_pll_state(u8 state)140140+{141141+ u8 value;142142+143143+ switch (state) {144144+ case VIA_STATE_ON:145145+ value = 0x20;146146+ break;147147+ case VIA_STATE_OFF:148148+ value = 0x00;149149+ break;150150+ default:151151+ return;152152+ }153153+154154+ via_write_reg_mask(VIASR, 0x2D, value, 0x30);155155+}156156+157157+static void set_secondary_pll_state(u8 state)158158+{159159+ u8 value;160160+161161+ switch (state) {162162+ case VIA_STATE_ON:163163+ value = 0x08;164164+ break;165165+ case VIA_STATE_OFF:166166+ value = 0x00;167167+ break;168168+ default:169169+ return;170170+ }171171+172172+ via_write_reg_mask(VIASR, 0x2D, value, 0x0C);173173+}174174+175175+static void set_engine_pll_state(u8 state)176176+{177177+ u8 value;178178+179179+ switch (state) {180180+ case VIA_STATE_ON:181181+ value = 0x02;182182+ break;183183+ case VIA_STATE_OFF:184184+ value = 0x00;185185+ break;186186+ default:187187+ return;188188+ }189189+190190+ via_write_reg_mask(VIASR, 0x2D, value, 0x03);191191+}192192+193193+static void set_primary_clock_state(u8 state)194194+{195195+ u8 value;196196+197197+ switch (state) {198198+ case VIA_STATE_ON:199199+ value = 0x20;200200+ break;201201+ case VIA_STATE_OFF:202202+ value = 0x00;203203+ break;204204+ default:205205+ return;206206+ }207207+208208+ via_write_reg_mask(VIASR, 0x1B, value, 0x30);209209+}210210+211211+static void set_secondary_clock_state(u8 state)212212+{213213+ u8 value;214214+215215+ switch (state) {216216+ case VIA_STATE_ON:217217+ value = 0x80;218218+ break;219219+ case VIA_STATE_OFF:220220+ value = 0x00;221221+ break;222222+ default:223223+ return;224224+ }225225+226226+ via_write_reg_mask(VIASR, 0x1B, value, 0xC0);227227+}228228+229229+static inline u8 set_clock_source_common(enum via_clksrc source, bool use_pll)230230+{231231+ u8 data = 0;232232+233233+ switch (source) {234234+ case VIA_CLKSRC_X1:235235+ data = 0x00;236236+ break;237237+ case VIA_CLKSRC_TVX1:238238+ data = 0x02;239239+ break;240240+ case VIA_CLKSRC_TVPLL:241241+ data = 0x04; /* 0x06 should be the same */242242+ break;243243+ case VIA_CLKSRC_DVP1TVCLKR:244244+ data = 0x0A;245245+ break;246246+ case VIA_CLKSRC_CAP0:247247+ data = 0xC;248248+ break;249249+ case VIA_CLKSRC_CAP1:250250+ data = 0x0E;251251+ break;252252+ }253253+254254+ if (!use_pll)255255+ data |= 1;256256+257257+ return data;258258+}259259+260260+static void set_primary_clock_source(enum via_clksrc source, bool use_pll)261261+{262262+ u8 data = set_clock_source_common(source, use_pll) << 4;263263+ via_write_reg_mask(VIACR, 0x6C, data, 0xF0);264264+}265265+266266+static void set_secondary_clock_source(enum via_clksrc source, bool use_pll)267267+{268268+ u8 data = set_clock_source_common(source, use_pll);269269+ via_write_reg_mask(VIACR, 0x6C, data, 0x0F);270270+}271271+272272+static void dummy_set_clock_state(u8 state)273273+{274274+ printk(KERN_INFO "Using undocumented set clock state.\n%s", via_slap);275275+}276276+277277+static void dummy_set_clock_source(enum via_clksrc source, bool use_pll)278278+{279279+ printk(KERN_INFO "Using undocumented set clock source.\n%s", via_slap);280280+}281281+282282+static void dummy_set_pll_state(u8 state)283283+{284284+ printk(KERN_INFO "Using undocumented set PLL state.\n%s", via_slap);285285+}286286+287287+static void dummy_set_pll(struct via_pll_config config)288288+{289289+ printk(KERN_INFO "Using undocumented set PLL.\n%s", via_slap);290290+}291291+292292+void via_clock_init(struct via_clock *clock, int gfx_chip)293293+{294294+ switch (gfx_chip) {295295+ case UNICHROME_CLE266:296296+ case UNICHROME_K400:297297+ clock->set_primary_clock_state = dummy_set_clock_state;298298+ clock->set_primary_clock_source = dummy_set_clock_source;299299+ clock->set_primary_pll_state = dummy_set_pll_state;300300+ clock->set_primary_pll = cle266_set_primary_pll;301301+302302+ clock->set_secondary_clock_state = dummy_set_clock_state;303303+ clock->set_secondary_clock_source = dummy_set_clock_source;304304+ clock->set_secondary_pll_state = dummy_set_pll_state;305305+ clock->set_secondary_pll = cle266_set_secondary_pll;306306+307307+ clock->set_engine_pll_state = dummy_set_pll_state;308308+ clock->set_engine_pll = dummy_set_pll;309309+ break;310310+ case UNICHROME_K800:311311+ case UNICHROME_PM800:312312+ case UNICHROME_CN700:313313+ case UNICHROME_CX700:314314+ case UNICHROME_CN750:315315+ case UNICHROME_K8M890:316316+ case UNICHROME_P4M890:317317+ case UNICHROME_P4M900:318318+ case UNICHROME_VX800:319319+ clock->set_primary_clock_state = set_primary_clock_state;320320+ clock->set_primary_clock_source = set_primary_clock_source;321321+ clock->set_primary_pll_state = set_primary_pll_state;322322+ clock->set_primary_pll = k800_set_primary_pll;323323+324324+ clock->set_secondary_clock_state = set_secondary_clock_state;325325+ clock->set_secondary_clock_source = set_secondary_clock_source;326326+ clock->set_secondary_pll_state = set_secondary_pll_state;327327+ clock->set_secondary_pll = k800_set_secondary_pll;328328+329329+ clock->set_engine_pll_state = set_engine_pll_state;330330+ clock->set_engine_pll = k800_set_engine_pll;331331+ break;332332+ case UNICHROME_VX855:333333+ case UNICHROME_VX900:334334+ clock->set_primary_clock_state = set_primary_clock_state;335335+ clock->set_primary_clock_source = set_primary_clock_source;336336+ clock->set_primary_pll_state = set_primary_pll_state;337337+ clock->set_primary_pll = vx855_set_primary_pll;338338+339339+ clock->set_secondary_clock_state = set_secondary_clock_state;340340+ clock->set_secondary_clock_source = set_secondary_clock_source;341341+ clock->set_secondary_pll_state = set_secondary_pll_state;342342+ clock->set_secondary_pll = vx855_set_secondary_pll;343343+344344+ clock->set_engine_pll_state = set_engine_pll_state;345345+ clock->set_engine_pll = vx855_set_engine_pll;346346+ break;347347+348348+ }349349+}
+76
drivers/video/via/via_clock.h
···11+/*22+ * Copyright 1998-2008 VIA Technologies, Inc. All Rights Reserved.33+ * Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.44+ * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>55+ *66+ * This program is free software; you can redistribute it and/or77+ * modify it under the terms of the GNU General Public88+ * License as published by the Free Software Foundation;99+ * either version 2, or (at your option) any later version.1010+ *1111+ * This program is distributed in the hope that it will be useful,1212+ * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even1313+ * the implied warranty of MERCHANTABILITY or FITNESS FOR1414+ * A PARTICULAR PURPOSE.See the GNU General Public License1515+ * for more details.1616+ *1717+ * You should have received a copy of the GNU General Public License1818+ * along with this program; if not, write to the Free Software1919+ * Foundation, Inc.,2020+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.2121+ */2222+/*2323+ * clock and PLL management functions2424+ */2525+2626+#ifndef __VIA_CLOCK_H__2727+#define __VIA_CLOCK_H__2828+2929+#include <linux/types.h>3030+3131+enum via_clksrc {3232+ VIA_CLKSRC_X1 = 0,3333+ VIA_CLKSRC_TVX1,3434+ VIA_CLKSRC_TVPLL,3535+ VIA_CLKSRC_DVP1TVCLKR,3636+ VIA_CLKSRC_CAP0,3737+ VIA_CLKSRC_CAP1,3838+};3939+4040+struct via_pll_config {4141+ u16 multiplier;4242+ u8 divisor;4343+ u8 rshift;4444+};4545+4646+struct via_clock {4747+ void (*set_primary_clock_state)(u8 state);4848+ void (*set_primary_clock_source)(enum via_clksrc src, bool use_pll);4949+ void (*set_primary_pll_state)(u8 state);5050+ void (*set_primary_pll)(struct via_pll_config config);5151+5252+ void (*set_secondary_clock_state)(u8 state);5353+ void (*set_secondary_clock_source)(enum via_clksrc src, bool use_pll);5454+ void (*set_secondary_pll_state)(u8 state);5555+ void (*set_secondary_pll)(struct via_pll_config config);5656+5757+ void (*set_engine_pll_state)(u8 state);5858+ void (*set_engine_pll)(struct via_pll_config config);5959+};6060+6161+6262+static inline u32 get_pll_internal_frequency(u32 ref_freq,6363+ struct via_pll_config pll)6464+{6565+ return ref_freq / pll.divisor * pll.multiplier;6666+}6767+6868+static inline u32 get_pll_output_frequency(u32 ref_freq,6969+ struct via_pll_config pll)7070+{7171+ return get_pll_internal_frequency(ref_freq, pll) >> pll.rshift;7272+}7373+7474+void via_clock_init(struct via_clock *clock, int gfx_chip);7575+7676+#endif /* __VIA_CLOCK_H__ */