|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ W% `! O1 ~3 t& m! H#include <linux/init.h>$ ?( i+ o5 o4 C+ R" X0 j" b
#include <linux/module.h>2 h3 I3 G' @/ S- X, K% n
#include <linux/kernel.h>$ ]) m+ a& y2 s. ?
#include <linux/types.h>3 ]- E6 S; a7 g Y6 M7 W! g- Y' ~( d
#include <linux/gpio.h>
2 F( R/ u4 H' q" _( t/ q#include <linux/leds.h> a( M, N& Q* `2 s
#include <linux/platform_device.h>3 v, s5 s7 g7 ~6 ^) Z q: v) Y# F0 y
! h/ z3 D: ? A, X5 ~2 k
#include <asm/mach-types.h>5 v+ `+ J+ |: _ ^8 k4 a
#include <asm/mach/arch.h>
3 k/ I I; }* ]8 Z0 ?7 `2 S% c#include <mach/da8xx.h>
0 v2 U, a. H0 ~3 s3 T7 P3 U7 R( R#include <mach/mux.h>* U' i) ]6 q) E C( k. f8 m7 r
) t: c, Z3 A# @) i9 h# [- I. _: u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' _+ X1 I9 Y' q1 X1 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# i1 Z. D' @ P$ w0 y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 W$ u6 ?& g' U% |' e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; _" T: O# X# g" A+ I& ~4 z0 L. ~6 Q0 ?
( H- t; f5 R( S( W/* assign the tl som board LED-GPIOs*/
0 E" v6 T" W9 q! f# Rstatic const short da850_evm_tl_user_led_pins[] = {
) R) o. O, V2 K* O, C3 ^' v4 r /* These pins are definition at <mach/mux.h> file */
) P0 k0 d4 M- W- w" x% e6 y8 H8 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; x3 }" e9 I# D8 C6 K5 k
-1
/ h, `9 }0 v$ O. M% _) M};2 U7 V& R4 ?9 o1 j- k: _
. ~: q5 j5 U) ^
static struct gpio_led da850_evm_tl_leds[] = {
5 B6 O# z. b6 [' f/ m {
; V! y( U' N$ l3 ?2 J1 \! _ .active_low = 0,
+ P$ `' O. k/ W) {$ d% j0 K, g3 H .gpio = DA850_USER_LED0,
. k$ \$ J. W5 o$ c" u ~ .name = "user_led0",5 r* |+ z, D. O8 T
.default_trigger = "default-on",
1 C4 \- W# g9 E4 Q5 c },& X5 [& U' T. R* m
{
, c. Y" f [* @% j. w N$ ~ .active_low = 0,3 @- t- E5 u) w, D
.gpio = DA850_USER_LED1,
' K& g) w3 _& g- g [% t2 a .name = "user_led1",
- B4 y& s" u* [- l$ Q .default_trigger = "default-on",
2 V" b1 p N& } },
: p, v( X7 H1 X' U8 {' j3 u {
% t# a, k* E$ {& U3 l6 P8 V .active_low = 0,0 ^9 r7 |5 P( Q$ \2 I( |* Z8 g
.gpio = DA850_USER_LED2,
& R7 y- C3 W) E$ T/ V .name = "user_led2",
' i2 C+ G' S2 H .default_trigger = "default-on",
8 _. @' w0 l9 k8 d+ j! E: d( O },
! Q$ V- a; W% o+ U6 i0 k {& d H3 h+ w9 j2 A1 V5 ]9 B
.active_low = 0,
1 i; K5 a4 V% W6 p1 T .gpio = DA850_USER_LED3,
9 p, Y# b, J e" A4 j .name = "user_led3",
1 Z# o T# N' \3 V& L .default_trigger = "default-on",
( }. n; g( c' a* z* e },4 v, |& E: ]9 L; E4 |& y2 O- D
};$ q4 _3 }! ?% w2 B$ J
7 W8 b% o6 l: I7 V9 K" F8 z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 @5 N! D, C6 a+ G
.leds = da850_evm_tl_leds,. `3 g' m U# S4 Z" l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 T* L) c% S* d8 {: J8 S* ?# @};
# ~/ o0 _- @# ]7 l6 ^ v5 W Y
3 K* q3 s' a( l: e7 Vstatic void led_dev_release(struct device *dev)( V ]) v8 N/ b) H
{, E8 N" s6 W' u" j# \
};
O$ H6 g# y: b% n3 E9 z; K' u3 R' B; b1 n6 r
static struct platform_device da850_evm_tl_leds_device = {. I' ~4 T4 h* \+ Y) `
.name = "leds-gpio",0 o1 b P. ?" I9 Q) E
.id = 1,' Z# D6 R$ h+ {6 N8 W+ w5 g+ b8 j
.dev = {7 M. V, g6 {# Y) f6 F+ N1 h1 {
.platform_data = &da850_evm_tl_leds_pdata,; j+ C/ r8 M2 V" q# W
.release = led_dev_release,
: L f" a6 d B _. c2 s }5 T4 z) K" h: @1 |
};, H4 L9 Y$ M x' `/ `! i# X
, j8 W2 L. Z; k' ~3 A( vstatic int __init led_platform_init(void)
8 Z6 b3 V, F7 a& f{
' m9 Q7 [# X; F+ w int ret;
, b5 B" ]& ^2 K. O1 u- T9 M#if 0% S* \0 L: k* ]5 W3 U
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: `8 g7 G/ R& ]( X: ~ if (ret)
5 |+ u$ z5 W. ~3 `: T8 Q9 D- e6 {4 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" J, }; S( G" n "%d\n", ret);7 Q7 F/ J" [- r, ~0 A5 i1 E
#endif$ o! d4 l' n, N
ret = platform_device_register(&da850_evm_tl_leds_device);/ ]5 r, F; _ o$ [3 c, {7 J; z
if (ret)
# c8 ]9 ~1 e% _4 ?4 u; x7 [ pr_warning("Could not register som GPIO expander LEDS");. C5 ]! P. n' v
else9 z( [' Z8 n! U- b9 m/ P
printk(KERN_INFO "LED register sucessful!\n");
4 `! U2 A1 I/ c
- i& v$ \& r% G5 T! c8 y# Q return ret;: r, _; i- U8 u) _
}
; x8 J5 P% r& e4 |0 X! @5 V( A5 z6 ~9 M1 f/ J* H1 L# C* O
static void __exit led_platform_exit(void)- X3 |) i: q& o' \# p, Q; E1 J- U; j
{
$ x6 N9 b. Z. k# b- D0 Z: p8 D platform_device_unregister(&da850_evm_tl_leds_device);3 k; e; G) \; x' m3 ^
& n& u9 U! D( i% E
printk(KERN_INFO "LED unregister!\n");5 m; Q5 c" R8 e5 Y' t& `* M$ Z" _5 K9 H
}( J! G1 x7 d& {/ ?) V% W# @/ n
9 _" x9 w9 f/ A$ q( M
module_init(led_platform_init);( x8 [7 {0 {5 b2 F; o9 w: c
module_exit(led_platform_exit);+ s8 l2 Z7 M" k" e$ U G
6 I" R. p* P5 P* K HMODULE_DESCRIPTION("Led platform driver");
9 m7 H0 Z4 o8 K3 y6 n/ s& [5 b) [MODULE_AUTHOR("Tronlong");/ x% H* W5 ?1 C* P1 f5 X/ c
MODULE_LICENSE("GPL");
. t# D S4 U1 }
$ l& ]7 G% q9 S0 s4 z8 K+ v6 R! ^ |
|