|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& N0 C% G5 b% p! f( z3 W" w8 S#include <linux/init.h># X* |3 L5 b0 a' k* E A9 v6 \! f! ^
#include <linux/module.h>. }. q' a5 h+ }. F& s
#include <linux/kernel.h>
9 [# f5 j9 Y G2 a* K6 e2 U& k- `8 T#include <linux/types.h>( r7 r* R, d: Y6 e2 H
#include <linux/gpio.h>! Z0 v5 v8 U k1 m) b+ d. u; W I
#include <linux/leds.h>4 R# O+ e- w; _( I: t. G
#include <linux/platform_device.h>' |' v% P- w, w# \& b0 M1 C' D
, n1 `+ S* n$ R% L
#include <asm/mach-types.h>! c- j0 ]8 U; `* `7 P
#include <asm/mach/arch.h>. C) [) u* k, K# i
#include <mach/da8xx.h>. |! V& q& n6 M: f
#include <mach/mux.h> J/ D* u. n- i2 R: z5 g! g; [
6 Y( e& A: }! F8 w i% l; f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" o* V. u. i1 U Z0 o. K2 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 u& R) O6 g: ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): L6 E0 X' S% l, m+ e8 R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) P4 \1 s9 [6 g+ [! _6 K7 N g$ B7 P
0 {( R/ _. _4 g0 {- d/* assign the tl som board LED-GPIOs*/
; k n2 | ^6 x) a/ c6 Z5 H& C0 ostatic const short da850_evm_tl_user_led_pins[] = {
8 Q F/ h, @' U+ T& ^5 G; u K /* These pins are definition at <mach/mux.h> file */
$ y4 Y2 M% O+ ]1 f$ K! A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," m# W; ]- c- A/ W
-1
! {/ I9 l k% h3 o};
) K5 B4 ~8 a& U+ H& L" H: P# C' M; K1 W& f( p X
static struct gpio_led da850_evm_tl_leds[] = {( p* ?& o8 i* c4 o) A; H
{
0 Y) Y" B# @. Z8 z3 W- [ a .active_low = 0,9 r' r9 {& ^& E* n5 S: W6 M
.gpio = DA850_USER_LED0,
6 u9 i6 E: c2 G5 y1 [' j: F .name = "user_led0",8 B5 l1 W$ }% F3 `& d' j4 a7 _
.default_trigger = "default-on",3 [3 [. B9 W1 g1 s
},1 G0 N. m& d$ K0 W+ O' R2 I y
{( _3 f: N. a. a+ E
.active_low = 0,: w0 Y* R; B& B- d
.gpio = DA850_USER_LED1,
7 S) K; {* m7 ?6 k .name = "user_led1",
7 H. e; C j& i& E. E# J. I .default_trigger = "default-on",
4 x3 ]2 I# S/ G7 x },
5 B; d3 o0 k, D& E1 t, x {& c" X1 Z% F, t5 ^/ i9 S* I \" |
.active_low = 0,
: C/ k2 _& l4 D' Y9 m3 r- r .gpio = DA850_USER_LED2,
' V# M- G% l' J0 ^2 g .name = "user_led2",9 U0 M/ c" H8 w) s+ }
.default_trigger = "default-on",0 `, N3 R# B% g1 q* i
},
- Q7 W+ d$ V! }" X+ K2 p2 a ? {
( I& k! }; p) _2 Q ^! M9 F .active_low = 0,
6 G4 h$ W4 S! N+ ~" y# K' \5 x .gpio = DA850_USER_LED3,% S5 \" W5 d; r* ]
.name = "user_led3",
8 r* D( v. Z: S# X4 p* l .default_trigger = "default-on",
`% \1 w8 G- S },
: {2 z# y7 | A1 y: G" O8 U};
' w& {0 ^" V! Z2 b2 A1 ?
1 [6 D2 w% V2 p$ Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 `! C; E- v# K0 `$ a/ Z0 k .leds = da850_evm_tl_leds,
3 `; C2 L0 G4 v/ x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 [9 K% R0 M5 p4 x! f5 }3 ?};
. W; Q D o/ G6 M7 v2 B. C: r# [; S* p! j4 ?+ D3 V
static void led_dev_release(struct device *dev)6 h3 c7 ~; e6 b6 o0 s
{
0 Z2 L* ~+ u9 V};
2 j0 f8 e4 B3 g3 d+ `0 C1 G2 O+ }% P# s
static struct platform_device da850_evm_tl_leds_device = {; c5 ]; ?" l, V. m2 A, a4 N
.name = "leds-gpio",) F f% b9 T4 j4 m+ R
.id = 1,% g6 H* S! P0 [# `: i
.dev = {
; Q* B8 x0 q; l) x8 A4 E3 e .platform_data = &da850_evm_tl_leds_pdata,
' c& u8 f H. J; f! b6 y a .release = led_dev_release,
& ?# b; t, c$ t6 l" H" v9 j1 I }
c/ a* Z5 l6 g' Z+ f% h};
* G: z. w% X3 i/ U, O
. G! M) c; e7 H# [( S( ystatic int __init led_platform_init(void)7 G/ @/ L/ O8 G+ ?
{( z2 ]) Z! {( K" X" G# P$ r2 S
int ret;; Q" _$ A5 v0 W: E2 \
#if 0! F; D3 w$ M+ R5 K% W5 W! G7 }7 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 y+ a# U. R' m. a' t0 Y
if (ret)
! x5 I! c1 ~) G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, S8 J9 e3 ~7 q "%d\n", ret);
2 n* r; e1 P( A+ N#endif
' K/ _7 \0 G0 F ret = platform_device_register(&da850_evm_tl_leds_device);! x3 z8 n" s2 e! B N
if (ret)
7 I' s' |) n3 S' Q q* u( J pr_warning("Could not register som GPIO expander LEDS");
% U2 T) {6 O2 N3 T& W' S/ K+ |% ^ else
1 n2 B* J5 C0 D* Q# j' j printk(KERN_INFO "LED register sucessful!\n");/ r5 y, r3 }4 Y9 v: h
2 u- H/ D6 D" M$ q0 _ return ret;$ I6 f" d2 X* C8 }+ Z7 L5 e; w9 f
}+ r7 _- b" L0 w2 H' I
f3 p [0 r! r- Q# I2 l: T% H5 H/ h8 [
static void __exit led_platform_exit(void)
/ K9 x; b$ H5 t) U/ w- n/ S{
# U8 p% N+ ] t) S9 `# K# c platform_device_unregister(&da850_evm_tl_leds_device);
: z# s& \& c% b4 a8 L+ V! G" M% N# S. b% J
printk(KERN_INFO "LED unregister!\n");! K; I# g( T6 @6 ~" r2 z
}( I ^; R J {' V0 F% q) U" \
. N5 D7 i: |2 g: v6 w( a
module_init(led_platform_init);" L- ~3 p+ z) [1 V" x
module_exit(led_platform_exit);' M. S% g$ i0 U; [: K9 D2 R
' p) V+ {( E- Z+ p/ r+ EMODULE_DESCRIPTION("Led platform driver");
( m* n1 m8 x# E ^+ }MODULE_AUTHOR("Tronlong");
! p1 i* I* W( m% TMODULE_LICENSE("GPL");4 c) ?" P! a, @
& o8 x9 W6 n$ d
|
|