|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 d+ b( U$ x: ^. m5 r+ j# c
#include <linux/init.h>' |0 K: s: N) _7 ?$ W8 O U
#include <linux/module.h>
# j) }1 H+ X7 _% @#include <linux/kernel.h>
! _1 {! C5 ~5 D, T9 a#include <linux/types.h>
0 G C3 k" K- p ?# U! l#include <linux/gpio.h>
' ~! h3 H# S& P+ V9 x#include <linux/leds.h>
9 W- _+ r: w6 a. _( r! V4 E* X#include <linux/platform_device.h>
0 i; E/ q) ^& G1 C- ^: j7 ~1 ?% z- p- N. B j
#include <asm/mach-types.h>% j& X# `6 W/ {( F5 M% B
#include <asm/mach/arch.h>$ q* d* Q$ J0 W9 }- g+ |3 S7 F* R
#include <mach/da8xx.h>
/ V: M$ x9 ]7 B/ I; \#include <mach/mux.h>- G; v; h* `! B/ E) N
( E+ Z7 \% {- }& J' R R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# k7 R% P( D1 X7 l( Z/ N$ u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) x5 j1 g) m* e4 R/ q0 M: J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 ~0 I' R5 a5 A4 \0 m3 ?$ T
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), Y. k2 Y" s) A
5 K6 h! u0 {0 }0 W& m' [, K
/* assign the tl som board LED-GPIOs*/$ ~9 \" j& @3 c% {" ^# a
static const short da850_evm_tl_user_led_pins[] = {2 z' {" E6 d. n) T- f: x
/* These pins are definition at <mach/mux.h> file */3 t A6 a+ X+ I: O: D6 o" i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# \1 E7 R( Z. u6 k
-1
: F. G9 _% j, C0 F5 h- b" r};! s7 H Y! S, \3 G# `
2 w( ^( Z' Z0 {" N; y9 `9 Z7 p
static struct gpio_led da850_evm_tl_leds[] = {8 ?6 ~$ t1 H! S; N1 H8 s
{
' H& K1 K! ]$ n* V .active_low = 0,( M5 w, q. D6 _# L# d9 B( i% ~
.gpio = DA850_USER_LED0,
7 J5 C8 q+ \" Q) j8 }2 \& r# ? .name = "user_led0",
1 L9 K& }. n* n" R- e+ f, o+ r .default_trigger = "default-on"," I( T6 U9 Y$ R! O. V
},
' {! g+ d4 |1 G X1 K) w# A) t% s$ o7 ` {) B9 o6 L) I9 ?" s: D y1 ^
.active_low = 0,
2 T, Y0 ~) R( O- R .gpio = DA850_USER_LED1,
) c: K0 l0 b4 q0 C# y .name = "user_led1",% a) Z/ P3 z; |; o( {
.default_trigger = "default-on",8 T; X) o8 W+ w( `; O; u* N
},/ c, u' B$ D" x/ w
{! b5 q" O( l- D7 F( @3 p5 Y; h3 h
.active_low = 0,
, B$ v' T+ \- N/ H. [ .gpio = DA850_USER_LED2,
0 `' g' t7 C6 `# J6 S, a% N .name = "user_led2",
4 q/ f- @! H7 C8 \, u+ F .default_trigger = "default-on",4 E3 H) ]& v5 Z, l, M. k
},
! {3 I" e9 \2 \& s: g6 A. Z {
" C* D1 q" C3 y0 w .active_low = 0,
% \5 L. ] a" W( `1 y, Q( o .gpio = DA850_USER_LED3," a) ~8 z5 d* c
.name = "user_led3",
" _6 g9 Z$ n ?# a9 f9 b. h .default_trigger = "default-on",; f/ y4 y u6 H/ } W
},$ r* p V/ n8 U' o$ y& X
};
& x0 b8 K. j# D1 P
: j# ]0 q4 R* S% k6 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, e0 j+ n {& \* d4 W4 o9 X- C .leds = da850_evm_tl_leds,' L4 p, r y& v/ B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 v7 f. @1 a3 h" E/ d& _" Y
};. D! n6 E* ]. V" c2 O7 d& `6 q
; J* O3 j9 V, c$ wstatic void led_dev_release(struct device *dev)4 M i( i6 s% @% I# q7 }9 E
{
* G! X1 c# w9 M8 Q3 r, U3 E& L};
; ]0 a4 z( O5 F: X A* _ _% R m3 I$ M, B8 c* t$ D
static struct platform_device da850_evm_tl_leds_device = {+ l* r7 O0 O" V: f3 C& q
.name = "leds-gpio",$ v5 X& F$ W4 u; Q- E X* l* K& [
.id = 1,
3 E5 q2 G) Z7 {4 ^# p$ C# V3 N8 h7 n .dev = {+ C2 ~1 t' p1 m2 `
.platform_data = &da850_evm_tl_leds_pdata,
* {. E' m* @; P: G6 h0 p$ s* z .release = led_dev_release,
, ]1 w( B. T) N& A6 J) n) @% A }
9 ~9 b- p6 o1 g. d};
2 l7 C) Z# r9 e* I* ^3 A/ U& s' b2 z# v9 T, F. j
static int __init led_platform_init(void)( O6 e- ^6 n+ T1 q" B
{
L% h( s4 i& C# E: B' D5 U int ret;1 r2 a1 y! \$ R5 c
#if 0/ C' l. e; W$ }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! d* K2 b* H$ t6 ]) F9 ~
if (ret)/ i) p: [ i1 ?0 L- _8 j: l D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ w9 j2 d% |' ?/ c
"%d\n", ret);1 w# }; e. p8 V2 J0 z# `
#endif
# n- U$ f0 M* g# r2 h+ X0 | ret = platform_device_register(&da850_evm_tl_leds_device);
5 @5 L+ e3 c4 N* g N5 q if (ret)
* m i, Z L# O3 | pr_warning("Could not register som GPIO expander LEDS");4 W, G, Q4 s& _. {7 y
else& K- {# ]3 g B. K
printk(KERN_INFO "LED register sucessful!\n");6 c+ s4 U- d8 K+ z; a5 l4 }
% ^3 J+ V, {! `$ B return ret;
1 N4 T% s7 d& S( i. v# L# l# Y}5 M+ J! S! j5 D
2 c! v- k1 s* Q! Z; i- c1 P
static void __exit led_platform_exit(void)
+ B5 g4 Z+ n3 m7 y4 M) N{
% Y6 z* Q5 K' M& x" R V9 z6 X; b; Z platform_device_unregister(&da850_evm_tl_leds_device);0 @# p; ^5 Q: v9 M: |! `
' H$ p) b& n; B$ H7 S$ A0 L printk(KERN_INFO "LED unregister!\n");
" k s. e" t8 X9 {}
/ |; v/ n) J# [7 Q4 d- n6 M! ^' Y/ Z. P# x! f& A, m( `# b
module_init(led_platform_init);
7 N/ q/ @$ t7 \7 [ W+ l. Emodule_exit(led_platform_exit);
+ y3 _; o9 u$ |) @/ M4 ~3 f. n% L, `7 `7 ~: k+ e
MODULE_DESCRIPTION("Led platform driver");
5 Y9 l% ]1 z" a2 v* @MODULE_AUTHOR("Tronlong");' d* }) ]1 g( ~6 Q
MODULE_LICENSE("GPL");$ T7 a' y: N5 W* F
6 n5 v( I1 E/ e7 u8 r5 p/ y
|
|