|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 x- D* N% ]* B! D#include <linux/init.h>
; l7 i9 q6 s3 B# B: |: q1 `% q4 n#include <linux/module.h>, s q$ R$ U- w" K- s2 W
#include <linux/kernel.h>
# j' a( D. a# r$ W- c#include <linux/types.h>* E9 h( R; X! L0 e: O# U4 z& c
#include <linux/gpio.h>' D) n3 R" e5 j1 @8 C$ N, n
#include <linux/leds.h>
$ R, m/ l0 \, @! [% u#include <linux/platform_device.h>
: y/ T! K$ ]( T' X0 `; U
5 d3 O9 o8 L1 s$ M#include <asm/mach-types.h>- {3 Y2 \! s) S
#include <asm/mach/arch.h># ]! I- s. ^, r: O
#include <mach/da8xx.h>
: P4 Q4 }/ \; |#include <mach/mux.h>
7 ]* ~! x2 Q" K3 ^, d1 c9 N
$ [% w L6 G) r7 }3 P% X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), c3 ?" g l; S: P0 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( F4 X7 R( V# `3 H, T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 R3 s! W3 l4 K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 C$ a6 W! P5 }- v
3 }0 L& H8 ]) m; v( h8 D/* assign the tl som board LED-GPIOs*/
+ F& ?* X4 Q# K! T& c, lstatic const short da850_evm_tl_user_led_pins[] = {
/ S! J# p* B {. m/ T /* These pins are definition at <mach/mux.h> file */. f: @1 l" Z& U; ]- o: U# S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' K3 O) E1 }* i1 U' \ -1' I/ d' k" M8 _6 F) d5 ?) {
};
/ O' x. R9 G- Q l( m( y
- K# h9 L5 b5 I2 i% g0 T; N/ estatic struct gpio_led da850_evm_tl_leds[] = {
7 l4 ~4 ]( L+ m; }1 @ {$ s ~9 k4 Y: q9 b# A* E$ {
.active_low = 0,
$ D" l; F6 i* t4 H4 q$ K3 C .gpio = DA850_USER_LED0,6 c+ O' ]0 x% S$ \
.name = "user_led0",7 Y9 }. I B& z& ?. E+ J
.default_trigger = "default-on",
/ i$ r3 N1 H. ?- S6 a) Y; d. ~ },6 Q9 q K2 E, }, X, j* O- \
{
; W h/ l9 f6 z0 ^3 a" s .active_low = 0,
) {2 d+ l8 h/ E6 } .gpio = DA850_USER_LED1,) g5 G; z8 ]4 A
.name = "user_led1",0 q1 b9 O7 \1 L: z1 G
.default_trigger = "default-on",: m( g( i0 l8 X7 a; s+ U
},
1 A$ r6 F6 H j% h6 k) h- k0 v1 t {' T: d/ r+ h; F+ a/ f. @
.active_low = 0,
: r" X7 d8 U1 i/ v' d .gpio = DA850_USER_LED2,6 J9 B# o/ r! e6 _: E
.name = "user_led2",% M) T3 H6 ~' r) M% L- s
.default_trigger = "default-on",
2 I. k) Z0 i( z, i. ] a },6 ?; l* ~7 T, ]) b
{
% o" W; D/ F8 j- h' |. U0 g .active_low = 0,% Z* K9 o# d! Y( t7 I F
.gpio = DA850_USER_LED3,4 W+ |5 L" ~5 z+ x2 d
.name = "user_led3",
. m4 ^& T( l8 E) f4 m: U6 n .default_trigger = "default-on",
. F5 h7 A# H8 z& T% ~! b9 W) B },$ U1 E" v5 ?7 S2 K. O
};* W0 T4 z$ o% `2 v* R, p
; @' f& K5 [' u" Q) u! s6 _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* T, M. @8 D" @: A# V! I8 w
.leds = da850_evm_tl_leds,* N) S1 L4 A6 `) |/ m7 k y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# l* L* f! `* Z( k+ H& r};, J" }* n2 e% F1 t1 `: T
/ f v5 ~% a) }2 @8 @* E+ P
static void led_dev_release(struct device *dev); C, q; h$ j& S6 D
{
^, j+ @- j2 R7 p; X};% Q5 I9 |7 A& `* r- Z) z
. U0 }: w3 P5 Z5 [& y# _
static struct platform_device da850_evm_tl_leds_device = {: } J* `; o! U$ ?
.name = "leds-gpio",! V. t. A I) x
.id = 1, ^- U$ }. j# i5 K, Z. C
.dev = {
% }/ |( ~" S+ Z* s4 J" _- x/ Z4 w .platform_data = &da850_evm_tl_leds_pdata,9 c5 P; J6 G2 w8 q% Z5 j3 O
.release = led_dev_release,
' y- l6 } e) ^# Y+ \ g) P }
# Q5 m5 B1 z9 w- G};
2 i7 K+ x8 g, ]! v+ r* z9 Z
! M- [0 D C; q! Fstatic int __init led_platform_init(void)1 B+ W) d0 x) V9 S3 G: _2 F
{
7 C8 `( T2 z! G% h, t. J" k int ret;
1 G5 e: |' Y+ Y. J) F% |3 N#if 0
, E( P& E# H) o& K ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 h$ O( f$ t7 x3 }% A z
if (ret)' f/ c6 a* M6 V* ]& V( \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 U9 k8 G) i) U3 a& |
"%d\n", ret);
3 l+ b4 S, n0 p7 r8 h#endif3 W9 o4 j7 |- d; i
ret = platform_device_register(&da850_evm_tl_leds_device);
# A5 g6 x# B$ g( `% r; j- ?2 _ O: [ if (ret)
" {7 U0 e! e% F& h6 F( |6 d pr_warning("Could not register som GPIO expander LEDS");0 ]; j2 L' v$ t
else
; Z- b n) o7 m7 K printk(KERN_INFO "LED register sucessful!\n");
+ Y1 a3 q! q+ d: e' l/ L. R; O
- g2 e1 ~* R5 s7 D' ~ return ret;# K9 g( f$ G# k
}0 y. Y$ K- d/ O) `' I
- o4 f) j- y$ B! m: N" R4 {
static void __exit led_platform_exit(void)
. i% Y! F7 d F0 z{, j9 [& Q# A* a
platform_device_unregister(&da850_evm_tl_leds_device);4 W( S# T7 O" P$ d2 R$ k) _
0 ^' t3 v2 T, n! b0 _2 r: m5 D- m+ s
printk(KERN_INFO "LED unregister!\n");8 e! p7 y8 V [4 t+ f3 U Y8 f
}
! d( V4 T" f6 l; a' A% q& _5 e* }! x+ o5 q* d
module_init(led_platform_init);$ E! V' C E9 V1 @1 N4 `
module_exit(led_platform_exit);# t# O7 ?9 Z$ t0 R1 l4 V( c
3 z8 F8 A- S" e8 Y7 Q/ ` D
MODULE_DESCRIPTION("Led platform driver");
- l9 y0 h5 W5 c m" Y. V; t0 E$ OMODULE_AUTHOR("Tronlong");
f# d$ u, _/ x- L. C1 _0 n: pMODULE_LICENSE("GPL");
. K) t4 O; D+ A5 `4 i) E, Q- F( D* O1 K; z* t, ^9 `1 e
|
|