|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' u6 ^. H% a/ x, U4 @% t#include <linux/init.h>- m" U2 _+ l0 R, q
#include <linux/module.h>
9 L5 @- {, a/ V' c#include <linux/kernel.h>* l# g c; j! Y0 o$ d# y7 x# `
#include <linux/types.h>
6 l% e( w( \% a; s#include <linux/gpio.h>' f6 j0 w2 V( c" M; R: N i
#include <linux/leds.h>/ F% T5 o( j1 |8 Z* W
#include <linux/platform_device.h>7 I9 P; |( a3 ~( g
0 ?. {4 F1 H7 E, h# V#include <asm/mach-types.h>9 k) u# Q5 e2 c' K, s+ H
#include <asm/mach/arch.h>
; s% R/ m2 B, \' q( j6 F" T#include <mach/da8xx.h>- |# h2 |' N) _9 l% W
#include <mach/mux.h>3 E9 u. O% S7 l5 }0 b
3 g8 {$ l9 I6 c# E4 I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 b( s; |( j" m; f" y/ k6 U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. \7 ]8 G& ~5 e0 f# v5 t( l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( a# g& v% m% E! g, w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% `% ~% Y. W' r6 X% j+ a1 F) _9 u7 m1 ?5 k* ~: c
/* assign the tl som board LED-GPIOs*/
/ @1 K2 a, o9 u5 b. N& P% _static const short da850_evm_tl_user_led_pins[] = {! j1 A$ k5 u9 p5 b. A6 D
/* These pins are definition at <mach/mux.h> file */9 W0 |" j* S* v, n$ ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 d, P. w6 l, _5 _8 ?* Q4 P# b9 M -16 L1 A0 O" t& z# m/ @
};) r& I8 |5 X9 y0 i& i2 a+ r2 Q
3 m! M7 ^! f+ p) \2 o( ]static struct gpio_led da850_evm_tl_leds[] = {8 K; q! o% S% b+ b
{
- `8 e- E2 @* l* g- `* z, [ .active_low = 0,
. e; G- P+ Z1 Q. H. \* V .gpio = DA850_USER_LED0,! {4 h( s) J! e- N# e. ?; x/ @ @
.name = "user_led0",
: q, T- f% D" I, y .default_trigger = "default-on",
; G6 P y1 Q: U, X% ` },: ^8 Z# J+ K. W' m0 m! `: P g
{' P- m" ]/ M) i' n3 o: Q
.active_low = 0,
& F5 j2 R+ [, t( d! J' F* } .gpio = DA850_USER_LED1,
* F2 Z2 Q( Y+ k5 e: U .name = "user_led1",
) c7 A% o$ y- u' K6 g6 k; l! T0 T .default_trigger = "default-on",
; m3 h$ f8 z) S7 i1 S. u },5 e6 A- Q" ~5 Q v# {% s9 B. E2 \
{* G* V# c6 C. K& P: j c- ^; q' I' R
.active_low = 0,3 ]' @8 i* \7 \/ h3 {7 l" c
.gpio = DA850_USER_LED2,( Z1 A* ^. \8 x0 P$ T
.name = "user_led2",0 U' F* R1 J R
.default_trigger = "default-on",
% D" h; H6 {# Y& X: D },7 E6 T7 [0 K4 }- J/ T# `; T
{
0 P d. J; y9 H' e .active_low = 0,
, k1 T% h9 K$ d1 s; I3 n .gpio = DA850_USER_LED3,
+ R4 V* I6 O+ j5 d' S .name = "user_led3",
; O7 b8 P- |( ]8 ?% L* b .default_trigger = "default-on",
+ o( k$ T, w/ D. [: g$ y. q' s },$ y0 o! C8 a: }) S2 N4 c5 G
};$ m- g7 H5 N* |$ m7 B7 d
' B4 h, l3 i9 V' i, P; @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: |6 p4 J p. \/ ]' D
.leds = da850_evm_tl_leds,/ J: Y4 o- m# n" y1 r* ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, }" U8 o+ t$ a* g0 m" ?' V
};& R0 T# H+ b$ u0 a) B4 @& K$ ]
$ J h# n& U, d$ m/ gstatic void led_dev_release(struct device *dev)
6 x9 I1 m9 M- ]- ^{. z) m0 }0 V' z3 e3 v& [4 `
};
$ A2 O8 I1 y: h! x& `7 S0 K& `
% i5 W! E6 }/ X* ^$ `' V" I* ?static struct platform_device da850_evm_tl_leds_device = {
2 L) ? ? \2 L .name = "leds-gpio",
# v- P8 K4 j3 C$ J .id = 1,
/ x/ [- j& a! R5 H7 }& D .dev = {" j# f$ f+ I, {7 f+ S( ?5 ^) q% C
.platform_data = &da850_evm_tl_leds_pdata,! p( S4 H% z" {8 v
.release = led_dev_release,6 `7 N- E$ b3 i- D, X0 I4 B. }$ [, k
}) j, k3 L! W: y( v
};
: w4 Y, V! o& u; S* Q" ~" G4 h' b( j& `
static int __init led_platform_init(void)
! @# x) U/ r! n; i, r# F: q% l{
+ [ ?3 p* `' l l' z4 l int ret;4 E+ p5 O% _3 \4 O# V3 i5 r
#if 0
1 [- f/ W* j3 n2 d+ D( S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; a" W k+ V% t7 H! K2 y v if (ret)
; P' c5 X2 f' Z* E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" w, ]! |: p) L& V @9 V" ^ "%d\n", ret);& t8 i3 j+ g) N* r4 K7 x# ]
#endif+ v$ U) r G5 G- a) N; [) J/ p
ret = platform_device_register(&da850_evm_tl_leds_device);
Q. `3 }$ l; x$ V; K if (ret)( K; |/ z$ ]' q- ~( H4 Z* C& o
pr_warning("Could not register som GPIO expander LEDS");9 w) V( k0 D* u* w1 h
else
?' b& l5 T) U7 y9 w printk(KERN_INFO "LED register sucessful!\n");
3 L9 a+ f% k; d( C3 ]0 K7 h
- c- q" g0 K! V$ r3 e! k* n, ] return ret;
8 {4 t2 V* t8 j8 h& U( g}
5 N/ v5 f$ _' ]+ `0 N- O& |# U" z) {& |2 \& E( l, @- ?! V9 ^4 U4 r: {
static void __exit led_platform_exit(void)3 y& Q+ d4 P6 S
{
" ?) O: Q) d' l1 B' v4 \ platform_device_unregister(&da850_evm_tl_leds_device);/ x3 a0 Q" E O- G
3 x: c1 e- L- Q/ V- ` printk(KERN_INFO "LED unregister!\n");
/ j4 U+ O3 g0 A% ]) s+ V4 c}4 f0 }; T" `6 W7 ^8 F' W, D
* `8 }" J E6 ^ _; D8 |* l
module_init(led_platform_init);
# N- B, X, v* t# x7 Lmodule_exit(led_platform_exit);3 a, U; V. B% `6 i4 G+ h) z
4 [: ?4 E* ?1 i5 L% ^: yMODULE_DESCRIPTION("Led platform driver");
+ T: K0 K0 g, q3 o9 |MODULE_AUTHOR("Tronlong");1 E, {5 P/ i; F1 x' A9 S+ d
MODULE_LICENSE("GPL");
/ p9 o( F0 L; o( N' w% Q& y; l& p" \! `+ _, _2 q
|
|