|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# G% O: [ I" w9 `) B#include <linux/init.h>8 R1 f- l5 i7 _! H6 {
#include <linux/module.h>! s! H" L& Z+ f7 ?7 n
#include <linux/kernel.h>+ q0 n f K* v7 W
#include <linux/types.h>
% v3 W, u$ f; }# ?; j#include <linux/gpio.h>
* q- L( X! g5 T3 G% I#include <linux/leds.h>
9 n$ Y- [0 c) T( E O+ D#include <linux/platform_device.h>
& k) k( T9 [8 U6 I" k4 k& T% g
8 @7 S" i* d- o- _#include <asm/mach-types.h> ]" a9 l* ~* n( x- e
#include <asm/mach/arch.h>" m# G4 G g8 k" _
#include <mach/da8xx.h>
9 Y# L/ |' b; N% o8 C#include <mach/mux.h>
% `) g% \0 }( K1 |, ]8 I
: q7 ^4 B" ~, S( Z' r$ O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). i3 s, ?; u E$ J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! b5 K& m" Y, r0 b) b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 ~2 k" a( f( _# A& y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! v" b# V* T: r* t: G
5 o. i' I) [# {" l! ]) z& o# U2 g0 ^/* assign the tl som board LED-GPIOs*/
: Z; E+ S+ ]5 M' u# S4 K' |( h V9 o% Istatic const short da850_evm_tl_user_led_pins[] = {3 n5 T" ~& ~3 O% f* p: s3 d
/* These pins are definition at <mach/mux.h> file */( I2 b* z2 ]6 z: b8 ?$ n! P/ |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* K& ?' ^6 x3 x2 |, L& u6 s/ `2 ]% k -1
+ T( {: y% W' h$ e, a};7 I% u' A! ?$ A/ H1 Z; O1 W3 n
* f0 A0 F0 A( X$ }2 m
static struct gpio_led da850_evm_tl_leds[] = {/ o2 \2 K6 ^( _: h8 r4 X
{4 }& \! @) X1 f# N. U6 a
.active_low = 0,; ]/ n" }. Y$ j0 J
.gpio = DA850_USER_LED0,& a1 C% V a& o9 Z, A6 d
.name = "user_led0",
, P# @+ X! }7 e% I" } .default_trigger = "default-on",5 q% ~3 R3 Y, _" v# O6 N
},& s$ e, B1 v9 A
{
0 @ `! S* a2 h% U; B! R .active_low = 0,
- x7 M4 S S$ \; a .gpio = DA850_USER_LED1,( h( Q% j7 Y8 x; a' T9 z, V( f4 W
.name = "user_led1",
z1 Q% x, {3 j5 G W .default_trigger = "default-on",5 w! W( w$ W7 ~5 [
},
0 {+ ^9 {/ w! G* B1 V {4 _) k6 c' O1 l! t% Q1 K
.active_low = 0,
! a1 z# ]% k1 q+ U .gpio = DA850_USER_LED2,/ |+ |0 p! s; B. ]. v. l4 o
.name = "user_led2",& g C6 P0 ^: ^
.default_trigger = "default-on",
# S+ I, t3 s9 U. E+ U+ @9 Z },
2 A6 x3 }' u! j# j# a {
# u% L0 @4 W! q1 a: q .active_low = 0,
$ V# d( `. |6 J% d$ f9 ^ .gpio = DA850_USER_LED3,/ a+ z% h+ I8 {( x8 N5 x" t7 f$ n% A
.name = "user_led3",: ^/ u* \2 V7 r) U" z' L
.default_trigger = "default-on",
) ~8 z& o5 p2 z! X, s5 r& B2 G4 ]; ~ },
! _+ |1 h% U+ Y2 l6 u P+ Q};. X/ ~6 B$ ^# s y& d# K" X/ V
+ A7 X5 p1 l: \ k8 z( b# H) w- rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 X# Q; t8 y7 ? .leds = da850_evm_tl_leds,1 D* l* p: s6 Z" J/ _$ u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& G1 R: n, h) C% c0 @$ [
}; B9 d, E% I9 `% G) r- {
" P# Q& k5 M' D l; Xstatic void led_dev_release(struct device *dev)
1 y" B% [" a* V) o8 @+ I. ]/ l{; A8 b9 b: g" F: @8 ^6 S8 S
};9 R; G+ F& O# j+ v/ n
* B+ c: ~' M( x; V' A9 Wstatic struct platform_device da850_evm_tl_leds_device = {
( D9 x9 M3 f$ I% v4 |1 Q3 G .name = "leds-gpio",
* Q- x& }( v5 T/ H T" S1 j4 l .id = 1,$ G# V- [7 S) {; Z; w
.dev = {6 Q# ^! A2 R9 ] U; B
.platform_data = &da850_evm_tl_leds_pdata,
6 l5 I- l- n( Z, s. \& E: d: i" V .release = led_dev_release,
6 b2 }3 I! _9 B! p7 r }
% x3 M9 U3 n$ o; C' `4 u8 w( s};
' v# K- ?9 \1 L# l! r% Z$ z$ e3 Y5 e9 M, Z( a# j% t+ h
static int __init led_platform_init(void)
. a" K1 G' R# \9 x0 e{* M4 d/ g. {% A+ G8 I' A
int ret;$ o# z) d/ ~) c: _, o8 ^2 @
#if 0
/ B6 ]( ]3 r7 i" k1 n- C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ Z. L0 d5 }6 u2 |# a if (ret)' Y0 {* @. ]1 B' {$ V Q& d7 G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" F+ {/ L+ Z' i q1 g' C
"%d\n", ret);: A: J- Z$ ^' F1 c" y" u5 Y
#endif! Q4 R! z4 w" ^. b" Z$ p
ret = platform_device_register(&da850_evm_tl_leds_device);
9 \6 b, |8 r3 [: W. Q- c if (ret)0 T! A3 V0 o" _2 p9 e0 a" F0 j" b
pr_warning("Could not register som GPIO expander LEDS");# ]& H4 T9 V3 D Z; e
else
, J. [- f) x0 W* y printk(KERN_INFO "LED register sucessful!\n");) P# ~! d1 a. ?" h) G& s7 ^
) R# v; Z9 l2 W/ T/ n
return ret;
$ W. W, j3 {, I}
$ |+ y9 e+ h# ^$ k
: b' X. j; ? r% _ ]$ zstatic void __exit led_platform_exit(void)
6 i! D4 H+ o# u, {6 C6 C2 l{
s% q7 ~8 M, c5 \( E3 c' j platform_device_unregister(&da850_evm_tl_leds_device);
N1 U. E9 z% J) U4 |% Q
4 _% J4 x# |0 e% c6 ?- R printk(KERN_INFO "LED unregister!\n");
Z( ~: g. S( T; z}
# `8 h3 F3 x, O* x5 A$ \( k4 X. W. U( Z& d, C
module_init(led_platform_init);
9 o5 f4 s+ f# J2 q: _module_exit(led_platform_exit);& R7 n# e- @7 B
: v7 P5 r! g9 a! Q0 R8 G: `2 _
MODULE_DESCRIPTION("Led platform driver");) d4 |3 q4 d3 ~; J! M4 Z* s) v2 y: E6 Q
MODULE_AUTHOR("Tronlong");- ?1 ?% f+ T" H9 q# a
MODULE_LICENSE("GPL");7 O! h! A6 @/ h5 _
8 X o; ?! R0 l/ h2 m
|
|